Skip to content

Commit ec95c5f

Browse files
lamaralFelixoid
authored andcommitted
Merge branch 'l_conditional_stage' into 'master'
Add conditional stage for scripted pipelines See merge request sysadmins/jenkins-adminsLib!12
2 parents 38a85b6 + 03fcba9 commit ec95c5f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

vars/when.groovy

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/groovy
2+
3+
// Kindly borrowed from: https://github.com/comquent/imperative-when
4+
// MIT License
5+
// Copyright 2018 by Comquent GmbH
6+
7+
import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
8+
9+
def call(boolean condition, body) {
10+
def config = [:]
11+
body.resolveStrategy = Closure.OWNER_FIRST
12+
body.delegate = config
13+
14+
if (condition) {
15+
body()
16+
} else {
17+
Utils.markStageSkippedForConditional(STAGE_NAME)
18+
}
19+
}
20+

0 commit comments

Comments
 (0)