Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-46558

when expression is not validated when Jenkinsfile is loaded by other Jenkinsfile

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Duplicate

    Description

      Jenkinsfile1:

       

       pipeline {
             agent none
             options {
                  skipDefaultCheckout()
              }
              stages {
                stage('SCM') {
                     agent {
                         label 'master'
                     }
                     when {
                        expression { env.JOB_BASE_NAME != "íntegrator" }
                     }
                     steps {
                         script {
                              if("${env.JOB_BASE_NAME}" != 'integrator') {
                                 checkout scm
                              }
                         }
                         echo "SCM stuff..."
                     }
               }
      .....
      

      Jenkinsfile2: (job integrator will load this one )

      node('master') {
           ... checkout pull request ...
           load Jenkinsfile1
      }
      

      For some reason the when expression doesn't get validated (even tried wit "JOB_BASE_NAME == hjehkfjhdfhkl", still the scm stage gets executed. The if statement in the script block currently does the trick, but should not be needed.

       

      Some background: The reasons why I load jenkinsfile in another are because I work on a very large project where we splitted the tests in groups/different pipelines for convenient and maintenance and other reasons. However on a pull request, all these are controlled from one pipeline.

       

      Attachments

        Issue Links

          Activity

            roel0 roel postelmans created issue -
            abayer Andrew Bayer made changes -
            Field Original Value New Value
            Component/s pipeline-model-definition-plugin [ 21706 ]
            Component/s pipeline [ 21692 ]
            Component/s pipeline-stage-step-plugin [ 21709 ]
            abayer Andrew Bayer made changes -
            Link This issue duplicates JENKINS-46547 [ JENKINS-46547 ]
            abayer Andrew Bayer made changes -
            Resolution Duplicate [ 3 ]
            Status Open [ 1 ] Resolved [ 5 ]
            bitwiseman Liam Newman made changes -
            Status Resolved [ 5 ] Closed [ 6 ]

            People

              Unassigned Unassigned
              roel0 roel postelmans
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: