Duplicate builds triggered on Jenkins multibranch pipeline

后端 未结 5 1824
生来不讨喜
生来不讨喜 2021-02-14 07:18

We are seeing duplicate builds triggered on Jenkins multibranch pipeline projects. Builds are normally triggered using push notifications from Bitbucket using this plugin: http

相关标签:
5条回答
  • 2021-02-14 07:50

    You indicated you're using https://marketplace.atlassian.com/plugins/com.nerdwin15.stash-stash-webhook-jenkins/server/overview. If you're still using that plugin, I suspect you'll be happier with what now seems to be the supported plugin for jenkins/stash (aka bitbucket server) integration: https://marketplace.atlassian.com/plugins/nl.topicus.bitbucket.bitbucket-webhooks/server/overview. Note how it says you need "at least this commit of the bitbucket-webhooks-plugin for Bitbucket server" in the bitbucket branch source plugin docs. We're using it and I've never seen two builds be triggered by the same push notification. When you trigger a build manually, yes, but not by the same push notification. :)

    0 讨论(0)
  • 2021-02-14 07:54

    You can add property "Supress Automatic SCM Trigger" to job configuration:

    Supress Automatic SCM Trigger Property

    This will prevent builds to execute due to "Branch Indexing".

    The downside is that you may need to manually trigger the branch specific build at least once to get the configuration applied from Jenkinsfile.

    0 讨论(0)
  • 2021-02-14 07:56

    As the other answer already suggested the "Do not allow concurrent builds" option is what you want. And you can get that via the Jenkinsfile:

     properties ([
          buildDiscarder(logRotator(artifactNumToKeepStr: '5', daysToKeepStr: '15')),
          disableConcurrentBuilds()
        ])
    

    EDIT:

    This is not the solution for the actual problem here. but it still seems helpful to some people, so I'll leave it as long as we don't have a better answer.

    0 讨论(0)
  • 2021-02-14 07:59

    In the Jenkins Multi-branch project config change "Discover branches" from "All branches" to "Exclude branches filed as PR".

    0 讨论(0)
  • 2021-02-14 08:07

    I'm using a multi-branch pipeline too and I may have some information for you.

    When you create a "GitHub organization" job in Jenkins and add the relevant Git information, you are also required to select how Jenkins builds are triggered and how often:

    Jenkins will scan the repositories under your configured GitHub organization as often as you set it.

    Then, Jenkins will automatically trigger a build as soon as it finds that a new commit has been committed (as long as the Jenkins-Git webhook is configured).

    When branch indexing takes place, it also triggers a build.

    In other Jenkins job styles you are able to configure "Do not allow concurrent builds" but I couldn't find this setting for a multi-branch job style.

    I hope this sheds some light on the matter.

    0 讨论(0)
提交回复
热议问题