Disable automatic trigger build jenkins multibranch

☆樱花仙子☆ 提交于 2021-01-29 06:29:18

问题


I have a multibranch project in jenkins, and every time I press Scan Repository Now it queue a new build just because

  ‘Jenkinsfile’ found
Met criteria

What I'd like to do is whenever I scan the repository, it only add Pull Request to the project without triggering a build. And also, if I turn on scan repository trigger, periodically if not otherwise run, every time it branch indexing, it also build the pull request even after I turn on Skip initial build on first branch indexing.

What I'd like to do is whenever there's a comment 'build' in the pull request, then it builds the branch, so if the pr doesn't contain the comment, it should not build anything.

How can I achieve this?

This is my setup

I use Jenkins 2.180


回答1:


According to the pipeline documentation there should be a option do dissable Index Triggers on Multibranch types, see https://jenkins.io/doc/book/pipeline/syntax/#options

But i didn't find the option itself either, so i deactivated it per Pipeline definition in the Jenkinsfile of every branch :/

overrideIndexTriggers

Allows overriding default treatment of branch indexing triggers. If branch indexing triggers are disabled at the multibranch or organization label, options { overrideIndexTriggers(true) } will enable them for this job only. Otherwise, options { overrideIndexTriggers(false) } will disable branch indexing triggers for this job only.

I also use SCM webhooks to autmatically trigger the branch indexing etc




回答2:


The default for Build Strategies is to OR the list together. You'll need to remove the existing build strategies and add an "All Strategies Match" build strategy and add "Change Requests" and "Skip Initial Build on First Branch Indexing" to that.

Source: https://issues.jenkins-ci.org/browse/JENKINS-58442



来源:https://stackoverflow.com/questions/56593931/disable-automatic-trigger-build-jenkins-multibranch

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!