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

when {branch} stage conditional regression

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • None
    • Jenkins 2.112
      Pipeline: API 2.26
      Pipeline: Model API 1.2.7

      The when branch conditional seems to still be broken. Similar to JENKINS-41012. In this case we are using GitHub with webhooks to trigger a build.  Following the good test code in 41012 I tested with the following. 

      Results - I get echo expression and echo env, but branch is always skipped. 

      Test pipeline code stage is:

      stages {
      stage('test condition: expression') {
      when {
      expression {
      return env.GIT_BRANCH == "origin/master"
      }
      }
      steps {
      sh 'echo "expression"'
      }
      }
      
      stage('test when: env') {
      when {
      environment name: "GIT_BRANCH", value: "origin/master"
      }
      steps {
      sh 'echo "env"'
      }
      }
      
      stage('test when: branch') {
      when {
      branch "origin/master"
      }
      steps {
      sh 'echo "branch"'
      }
      }
      }
      

            abayer Andrew Bayer
            ericnelson Eric Nelson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: