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

Multibranch Pipeline broken on when expressions on tag

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • pipeline
    • None

      When using 'when' expression, multibranch pipeline does not skip the condition but executes the stage.

      I've 3 stages, Build, Deploy to QA and Prod (which is not show in the snippet. Build has nested stages with when condition. I want to build from any branch or tag starts with release/*. hence I have a when condition in Build Stage (nested).

      Then when it come to deployment, I want Deploy to QA to be executed when 'when' expression matched to the release.* "REGEX". But instead of skipping on any branch, it executes the stage.

      Pipeline: 

      pipeline {
          agent none
          stages {
              stage('Build') {
                  agent {
                      node ('master')
                  }
      
                  stages {
                      stage ('Setup') {
                          agent {
                              node {
                                  label ''
                              }
                          }
                          when {
                              branch '**'
                              tag pattern: "release.*", comparator: "REGEXP"
                          }
                          steps {
                                   //some stuff here
                                  }
                              }
                          }
                      }
                  }
              }
              stage('Deploy to QA') {
                  agent {
                      node {
                          label ''
                      }
                  }
                  when {
                      tag pattern: 'release.*', comparator: "REGEXP"
                  }
                  steps {
                      //some stuff here
                          }
                      }
                  }
              }
          }
      }
      

            Unassigned Unassigned
            puneet0803 Puneet
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: