简体   繁体   中英

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.

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. 在此处输入图片说明

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

If you want to avoid builds from jenkins whenever you do a push to bitbucket you can disable the hook of the bitbucket repository. To add , remove and modify hooks you need to be the owner of the repository. You need to have priveleges. If you disable the hook that signalizes the automated jenkins build then you can push to every branch you want without triggering automated builds from jenkins.

In the link below you can find more information about hooks in bitbucket:

https://confluence.atlassian.com/bitbucketserver/using-repository-hooks-776639836.html

The hook is calling the jenkins job run an automated build. The hook can be triggered by : push event, Tag push events , merge request events and etc... Disable that hook that has the triggers that you don't want . Or disable the event of the hook , without disable the entire hook.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM