Search code examples
gitjenkinsjenkins-pipelinebitbucket

How to avoid a created branch to be build in Jenkins?


In our team we create branches with a Bitbucket integration through JIRA. Thus, the branches are pushed to Bitbucket and then usually checked out by a developer to work on.

The push to Bitbucket triggers a build of the branch in Jenkins. This build is unnecessary as it builds the latest commit of the base branch which has already been build. How can we avoid/skip this build? We're use declarative pipelines.


Solution

  • For Multi-Branch Pipeline Job, if you are using Bitbucket Plugin https://plugins.jenkins.io/cloudbees-bitbucket-branch-source/ for Branch Sources, then there is a way which can help to not trigger Jenkins job when a new Branch is created.

    Install Basic Branch Build Strategies Plugin https://plugins.jenkins.io/basic-branch-build-strategies/. Installing this provides an option in Bitbucket Plugin to skip first execution. enter image description here

    By this the initial execution done during branch creation can be skipped.