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

when condition not correctly discovering branch

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Critical Critical
    • None
    • Pipeline Model Definition Plugin: 1.2.2

      I created a new pipeline job and defined "Pipeline script from SCM" using Git:

      • repo Url: git@bitbucket.org:yooture/xxx.git
      • branch specifier: */master
      • Repository browser: (auto)
      • Additional Behaviours: none
      • Script Path: Jenkinsfile
      • Lightweight checkout: on

      In have the following simple pipeline:

       

      pipeline {
        agent { label 'lxc-fedora25' }
      
        tools {
          maven 'MVN_352'
          jdk "Oracle JDK 1.8 (latest)"
        }
      
        stages { 
          stage('build Snapshot') {
            when { not { branch 'master' } }      
            steps {
               sh 'mvn clean install -Dmaven.test.failure.ignore'
            }
          }
          stage('Build Release') {
            when { branch 'master' }
            steps {    
                sh "mvn clean deploy"
            }
          }      
        }
      }

       

      even though the branch specifier is specified as "*/master", "build Snapshot" stage is always executed

       

       

            abayer Andrew Bayer
            imod Dominik Bartholdi
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: