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

cron job trigger for multibranchPipelineJob DSL

XMLWordPrintable

      Hi,

       

      I'm using multiBranchPipeline DSL to create a jobs like that:

      multibranchPipelineJob('${jobName}') {
          branchSources {
              git {
                  remote('${repo}')
                  credentialsId('${credentialsId}')
                  includes('${branches}')
              }
          }
          orphanedItemStrategy {
              discardOldItems {
                  numToKeep(20)
              }
          }
          configure {
              it / factory(class: 'org.jenkinsci.plugins.workflow.multibranch.WorkflowBranchProjectFactory') {
                  owner(class: 'org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject', reference: '../..')
                  scriptPath('${jenkinsfilePath}')
              }
          }
      }

      Everything works fine, but now I want to trigger job automatically by cron.

      According to docs I can use https://jenkinsci.github.io/job-dsl-plugin/#path/multibranchPipelineJob-triggers-cron

      But it doesnt work for me.  I'm adding this to DSL snippet:

      triggers {    cron('@daily')}

      But Build Triggers section for the job is completely virgin.

      Am I missing something there? How can I debug this problem?

       

      UPDATE
      In job's config.xml I found this section:

      <triggers>
          <hudson.triggers.TimerTrigger>
              <spec>@daily</spec>
          </hudson.triggers.TimerTrigger>
      </triggers>

            Unassigned Unassigned
            spugachev Stanislav Pugachov
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: