Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Duplicate
    • Labels:
      None
    • Environment:
    • Similar Issues:

      Description

      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

       

       

        Attachments

          Issue Links

            Activity

            There are no comments yet on this issue.

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                nicolasus Nico Navarrete
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: