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

trigger properties in scripted pipeline require 2 builds to get registered

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • workflow-job-plugin
    • None

      When defining trigger in a declarative pipeline, it will suffice to write

      pipeline {
       agent any
      
       triggers {
         cron('H H(0-7) * * *')
       }
      }

      and build once. 

      After the first build accessing the job config UI will show the trigger configuration.

      However if you do the same thing with a scripted pipeline

       

      node {
          properties([pipelineTriggers([cron('H H(0-7) * * *')])])
      }
      

       

      you need two builds to register the trigger (it won't appear in the UI and won't be working until the second manual build).

       

          [JENKINS-49502] trigger properties in scripted pipeline require 2 builds to get registered

          Andrew Bayer added a comment -

          What versions of core, workflow-job, and workflow-multibranch are you using when you see this?

          Andrew Bayer added a comment - What versions of core, workflow-job , and workflow-multibranch are you using when you see this?

          abayer sorry for the late.

          core 2.89

          workflow-job 2.17

          workflow-multibranch NA (not installed in my tests)

          valentina armenise added a comment - abayer sorry for the late. core 2.89 workflow-job 2.17 workflow-multibranch NA (not installed in my tests)

          mike cirioli added a comment -

          FWIW - I just had to do a test for a blog post i am writing and when using pipeline-event-triggers, you only need to run a build once (declarative or scripted) using 2.107 core.

          mike cirioli added a comment - FWIW - I just had to do a test for a blog post i am writing and when using pipeline-event-triggers, you only need to run a build once (declarative or scripted) using 2.107 core.

          mike cirioli added a comment -

          quick update - i have re-verified that you no longer need to run a scripted job with triggers twice in order to have them registered. Closing this issue.

          mike cirioli added a comment - quick update - i have re-verified that you no longer need to run a scripted job with triggers twice in order to have them registered. Closing this issue.

          We are also encountering this issue

           node ('centos-small') {
                  properties([
                      pipelineTriggers([cron('H/5 * * * *')]),
                  ])
          

           The trigger is not visible in the UI until the job is manually triggered twice. It is visible in the config.xml from the first run.
          The cron trigger is not executed until we manually trigger the job twice ( corresponds to when it is visible in the UI)

          Jenkins ver. 2.121.3
          Pipeline ver. 2.5

          Liam Rae-McLauchlan added a comment - We are also encountering this issue  node ('centos-small') { properties([ pipelineTriggers([cron('H/5 * * * *')]), ])  The trigger is not visible in the UI until the job is manually triggered twice. It is visible in the config.xml from the first run. The cron trigger is not executed until we manually trigger the job twice ( corresponds to when it is visible in the UI) Jenkins ver. 2.121.3 Pipeline ver. 2.5

          Is there a way to programmatically make it visible in UI? In groovy I mean

          Stanislav Pugachov added a comment - Is there a way to programmatically make it visible in UI? In groovy I mean

            Unassigned Unassigned
            varmenise valentina armenise
            Votes:
            2 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: