Currently I have configured in the Jenkins multibranch pipeline so that dev, stage, uat and prod branches get indexed. When I'm creating PRs from any feature branch to the dev branch, only dev branch gets indexed which is correct, but when I do a PR from dev to stage, for example, both the stage and dev branches are getting indexed which shouldn't happen, only the target branch stage should get indexed, without source branch dev.
My current configuration looks like this:
What should I change so that always only the target branch to which PR is merged to is going to get indexed? In my example, only stage branch, when the PR is coming from dev?
After a bit more testing I have noticed that the dev branch gets crossed out when a PR is created to the stage branch and after approval of PR and merge the dev branch is not crossed out anymore. This action is detected in Jenkins as if the branch is newly added and there for it indexes the branch again.
The solution was to set the Discover branches Behaviour to All branches. That prevented 'excluding' the dev branch from discovery and therefore the branch doesn't get indexed again after the PR merge.
Related
I use Jenkins with a multibranch pipeline and I want the pipeline to be executed when there is
a PR from any branch to dev
a commit to any release/** branch
But I cannot get the configuration to discover the commits. My configuration is:
Which I thought would do:
Take all commits in dev and release/** and all PRs to those branches.
What it actually does: only commits on dev and release/**, all PRs are ignored.
What do I have to change?
I am not sure if I am asking the question in right way.
When I am triggering the multi branch pipeline job and I do "checkout scm" in Jenkinsfile, does it checkout the pull request or Master + pull request?
It depends of your settings.
As I remember, multibranch pipeline builds pull requests in separated view and it can build as PR source branch and result of PR. It cloned your repo, checkouts target branch, merges source branch into it and runs your stages.
If you look at the logs you will see that it checks out the hash of the commit
example: git checkout 1fb651dfdcbea276627de0247bbf5047840cae4c
As for workspace, if you log in to the Jenkins machine where this is running you will see that each branch has a separated workspace. Here you will find the source code of the checked out branch. The separated workspace ensures that there is no conflict when working with multiple concurrent branch builds.
We use the gitflow branch strategy to maintain our repositories. This is linked to a multibranch pipeline in jenkins. That all works just fine.
Im wondering if it's possible to prevent building the master branch if another branch, let's say develop, has failed.
Usually we merge all code into develop, then into master for deploy. So if develop is failing, we'd prefer not to build and deploy master.
Instead of preventing a build on master, you shouldn't be merging. Only merge to master if your build on develop was successful and passed all tests.
Even when it comes the the merge - you can merge in a new 'merge branch' (taken from master) and deal with any conflicts/issues, test the build on that, and only if that succeeds does the actual merge to master take place.
Hope this helps.
I'm working with BitBucket and VSTS to build a standard CI pipeline.
Development team works on a feature branch. When their work is complete, they merge their code into development branch.
I would like a way to enforce a test execution prior to merging the feature branch into development branch. Ideal situation would be something like this:
The developer creates a pull request.
The code review process is approved.
The developer does SOMETHING, which triggers some process that merges the feature branch with the development branch (feature branch could merge into development branch, or a brand new branch is created with the two branches merged, or something else).
The merged branch is built, deployed, and test executed against it.
Test pass: branch is merged into development branch.
Test fail: feature branch does not merge into development branch (if the branch is already merged into development branch, then the merged commit is reverted out of development branch).
The goal of this process is to keep development branch at a "good" condition.
Typically, the SOMETHING which triggers all this process is the act of committing (or merging) a code into the development branch. The trouble with this process is reverting the code out of the development branch if the tests fail without loosing the code. (It's possible that the merged branch has been deleted at this point).
There is build Pull Request feature in VSTS build, so you can create a new build definition with Build pull requests enabled, then the build will be triggered once a new pull request be created and match the target branch, you can check the build result in pull request in bitbucket.
You can define the policies through checklist: Pull request guidelines for Bitbucket Cloud.
BTW, the VSTS includes branch policies feature, so you can consider using VSTS repository.
We are working on a POC with Bamboo and Bitbucket to do an auto-merge between the Master and Feature branches.
The task list is as follows:
Commit code in trunk
Get a repository polled bamboo build for the Trunk
Code gets Auto-merge in feature branch
Get a repository polled bamboo build for the Feature
I am able to do the first two steps but the next two are coming through.
What can be the configuration issue in this plan?
Thanks
You can establish automerging from your Bamboo plan.
Go to Plan Configuration -> Merging -> Branch merging enabled and you have 2 options:
Branch updater
Gatekeeper
For your user case you can use Branch updater, selecting the merged from the branch that you want and pushing on the branch that you want.