-
Bug
-
Resolution: Duplicate
-
Minor
-
None
When section doesn't get evaluated (stage always executed) when the pipeline {} definition is inside a shared library
@Library('jenkins-pipelines') _ ContinousIntegrationBoot { SKIP = [SCM:false, BUILD:false, TEST:false, QA: true, IT: true, DEPLOY: false] MAILS = ["xyz@xyz.es"] }
The when sections are not evaluates and we must check with if{} in script{} section ....
def call(body) { // evaluate the body block, and collect configuration into the object def config = [:] body.resolveStrategy = Closure.DELEGATE_FIRST body.delegate = config body() pipeline { options{ skipDefaultCheckout() } agent none // node stages { stage('scm') { when{ // Not executed when inside the library expression{ echo "Skip scm EXPRESSION is ${config.SKIP.SCM}" return !config.SKIP.SCM } } agent any steps { echo "Skip scm is ${config.SKIP.SCM}" script { if(!config.SKIP.SCM) { deleteDir() checkout scm } } } } ......................................
Thanks
- duplicates
-
JENKINS-42224 Need ability to create reusable chunks of Declarative Pipeline
- Open