Jenkins Multi-branch pipeline doesn't schedule

2020-03-17 03:52发布

I'm trying to get Jenkins' multibranch pipeline job to build tags in a similar manner to branches. In Jenkins 2.73 (not sure when the functionality was added), Multibranch projects can be configured to retrieve both branches and tags from the source repository. Initially I thought this would be perfect for my needs (my Jenkinsfile can now build development or production builds from the same place in Jenkins). Multibranch job with tags discovery configured

I have the build process itself up and running quite happily with a scripted pipeline, however my issue is that whilst the branch jobs pickup my triggers perfectly (Cron weekly) and are thus triggerable using the Git plugin's notifyOnCommit functionality (allows me to clean build weekly, but build on commit to the repo as well via a repo scan webhook), tag builds do not.

Has anyone else come across this? If so, have you found any reasonable way to resolve it?

Relevant snippet from my scripted pipeline (I tried with and without the overrideIndexTriggers setting): properties( [ pipelineTriggers( triggers: [ cron('H 02 * * 7') ] ), overrideIndexTriggers(true) ] )

Polling configuration from a branch job generated by the multibranch pipeline seems fine Jobs generated from tags by the multibranch pipeline do not receive the same configuration, bizarrely...

There is a note in the multibranch pipeline scan log that suggests that Tags will never be auto-scheduled: Processed 8 branches Checking tags... Checking tag testing ‘Jenkinsfile’ found Met criteria No automatic builds for testing Processed 1 tags [Mon Oct 23 09:55:00 UTC 2017] Finished branch indexing. Indexing took 8.1 sec Finished: SUCCESS

My project is docker based and I would like to run a release build weekly, to pull in any base-image changes etc.

Does anyone have any ideas about what I can do to get multi-branch projects to schedule tag builds?

1条回答
闹够了就滚
2楼-- · 2020-03-17 04:44

Not automatically triggering a build for discovered tags seems to be by design according to JENKINS-47496. Stephen Connolly offers an explanation and suggestion for what you might do:

Stephen Connolly added a comment - 6 days ago

Tags are not built by default (because otherwise you could have a build storm when checking out a repository) and worse, the order tags will be built in is unpredictable... and you might have a Jenkinsfile that deploys to production when a tag is built.

There is an extension point in branch-api called BranchBuildStrategy which - if implemented - will allow deciding whether to build tags.

See https://github.com/jenkinsci/github-branch-source-plugin/pull/158#issuecomment-332773194 for starting point on how to create such an extension plugin... I believe there is some work on one at https://github.com/AngryBytes/jenkins-build-everything-strategy-plugin

查看更多
登录 后发表回答