1

I am trying to create a cron job which run some smoke tests every 10 minutes, my seedjob looks like this :

multiBranchJobs.each { currentJob ->
    multibranchPipelineJob(currentJob.name) {
        branchSources {
            git {
                remote(currentJob.projectGitUrl)
                credentialsId(currentJob.credentials)
                includes(currentJob.includes)
            }
        }
        orphanedItemStrategy {
            discardOldItems {
                numToKeep(20)
            }
        }
        triggers {
            cron "H/5 * * * *"
            periodic 60
        }
    }
}

the problem with the current approach is that it will get executes only if it detects changes in the SCM, which is not the case for the smoke tests. I need to run it every 5 minutes regardless of commits in source control. Any clue ?

Bob Zant
  • 215
  • 4
  • 16

1 Answers1

0

I'm not entirely sure how to solve your problem, but I think the cron trigger you have is not doing what you think it is. I THINK this will set this trigger on the multibranch indexing job itself. In the UI that is not even an option. Apparently it isn't throwing an error, but I have to wonder if it is actually setting the trigger.

The jobs that get created from the multibranch job must have a Jenkinsfile, right? You can set the triggers in those Jenkinsfiles.

I haven't built jobs using code, so take that into consideration when you review my answer. But it SEEMS to me that you are setting the trigger in the wrong place.

Rob Hales
  • 5,123
  • 1
  • 21
  • 33
  • Yes, the trigger should be defined in Jenkinsfile, see https://jenkins.io/doc/book/pipeline/syntax/#triggers – daspilker Oct 18 '17 at 18:02
  • changing the created job into a pipelineJob did the trick, because multibranchPipelineJob triggers a SCM scan to check if there is new commit. – Bob Zant Oct 20 '17 at 10:59