From 5a392aae0a6e32ba5ea8c5df3a649078b1483d7e Mon Sep 17 00:00:00 2001 From: Dan Beghin Date: Tue, 24 Sep 2024 15:56:05 -0500 Subject: [PATCH] Add 'soft_fail' to CommandStep (#8) --- build.gradle | 6 ++++++ .../com/widen/plugins/buildkite/BuildkitePipeline.groovy | 8 ++++++++ .../groovy/com/widen/plugins/buildkite/idea/pipeline.gdsl | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/build.gradle b/build.gradle index 759f229..92454fa 100644 --- a/build.gradle +++ b/build.gradle @@ -82,6 +82,12 @@ buildkite { } } + commandStep { + label ':boom: Soft fail step' + command 'soft-fail.sh' + softFail(1, 127) + } + waitStep() commandStep { diff --git a/buildSrc/src/main/groovy/com/widen/plugins/buildkite/BuildkitePipeline.groovy b/buildSrc/src/main/groovy/com/widen/plugins/buildkite/BuildkitePipeline.groovy index 7027297..28d8f09 100644 --- a/buildSrc/src/main/groovy/com/widen/plugins/buildkite/BuildkitePipeline.groovy +++ b/buildSrc/src/main/groovy/com/widen/plugins/buildkite/BuildkitePipeline.groovy @@ -668,6 +668,14 @@ class BuildkitePipeline implements ConfigurableEnvironment { void branches(String... branches) { model.branches = branches.join(' ') } + + void softFail(boolean softFail = true) { + model.soft_fail = softFail + } + + void softFail(int... exitStatuses) { + model.soft_fail = exitStatuses.collect { exitStatus -> ['exit_status': exitStatus] } + } } /** diff --git a/buildSrc/src/main/groovy/com/widen/plugins/buildkite/idea/pipeline.gdsl b/buildSrc/src/main/groovy/com/widen/plugins/buildkite/idea/pipeline.gdsl index 9f41998..106067f 100644 --- a/buildSrc/src/main/groovy/com/widen/plugins/buildkite/idea/pipeline.gdsl +++ b/buildSrc/src/main/groovy/com/widen/plugins/buildkite/idea/pipeline.gdsl @@ -58,6 +58,10 @@ contributor([ctx, closureCtx]) { method name: 'automaticRetry', params: [body: Closure], doc: 'Retry this step automatically on failure.' method name: 'skip', doc: 'Skip this step.' method name: 'skip', params: [reason: String], doc: 'Skip this step with a given reason string.' + method name: 'softFail', params: [softFail: Boolean], doc: 'Soft fail this step.' + method name: 'softFail', params: [exitStatuses: 'java.lang.Integer[]'], doc: ''' + Soft fail this step for the given exit statuses. + ''' method name: 'timeout', params: [timeout: 'java.time.Duration'], doc: ''' The amount of time a job created from this step is allowed to run. If the job does not finish within this limit, it will be automatically cancelled and the build will fail.