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

per branch cron trigger work-around changed all of my PRs

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Critical Critical
    • core
    • None
    • Jenkins 2.263.4

      I have been using the per-branch cron build trigger work-around as such:

          triggers {
              cron(env.BRANCH_NAME == 'master' ? 'TZ=America/Toronto\n0 0 * * *\n' : '' +
                   env.BRANCH_NAME == 'release/1.2' ? 'TZ=America/Toronto\n0 12 * * *\n' : '')
          }
      
      

       Successfully on our master branch (where PRs are usually branched from) for quite some time.  I wanted to add a new one so I added:

                   env.BRANCH_NAME.startsWith('weekly-testing') ? 'H 0 * * 6' : ''
      

      to the string that is evaluated inside the cron() function above such that it's now:

          triggers {
              cron(env.BRANCH_NAME == 'master' ? 'TZ=America/Toronto\n0 0 * * *\n' : '' +
                   env.BRANCH_NAME == 'release/1.2' ? 'TZ=America/Toronto\n0 12 * * *\n' : '' +
                   env.BRANCH_NAME.startsWith('weekly-testing') ? 'H 0 * * 6' : '')
          }
      

      Ever since doing that, every single GitHub PR that has merged master, including that change above has had it's configuration (i.e. config.xml) changed such that:

      <org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
        <triggers>
          <hudson.triggers.TimerTrigger>
            <spec>H 0 * * 6</spec>
          </hudson.triggers.TimerTrigger>
        </triggers>
      </org.jenkinsci.plugins.workflow.job.properties.PipelineTriggersJobProperty>
      

      has been added to it. This of course now means that every PR is triggering on the schedule that should only apply to weekly-testing*.

      This obviously never happened with either of the env.BRANCH_NAME == … ? … : … ternary expressions (given how long they have existed in my Jenkinsfile, so why is it now happening with the addition of the env.BRANCH_NAME.startsWith()?

            Unassigned Unassigned
            brianjmurrell Brian J Murrell
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: