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

when triggeredBy SCMTrigger does not work

XMLWordPrintable

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

      I have a working multibranch pipeline and am trying to add a conditional stage that only runs when the branch is main and the build is triggered by code being pushed/merged or a release tag is added.  My stage looks like this:
      stage ('Sync') {
      when {
      branch 'main'
      anyOf

      { triggeredBy 'SCMTrigger' tag 'release-*' }

      }
      steps {
      build job: "wkt-sync"
      }
      }
       
      In the Jenkins job triggered by the GitLab Branch Source Plugin, I see:
      Push event to branch main
      Started by GitLab push by Robert Patrick
      Querying the current revision of branch main...
      Current revision of branch main is 38d353c06e85d83af79a6e599c098a9d0203727d
      Obtained Jenkinsfile from 38d353c06e85d83af79a6e599c098a9d0203727d
       
      But when the job runs, I see:

      {{}}
      [Pipeline] // stage
      [Pipeline] stage
      [Pipeline] { (Sync)
      Stage "Sync" skipped due to when conditional
      [Pipeline] }

      What am I doing wrong? 

            Unassigned Unassigned
            rhpatrick Robert Patrick
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: