I have some old release branches in git: release/2022.1, release/2022.2, release/2022.3.. I have some old ones for the previous years as well.
Now starting from branch release/2022.4 and for the following years from now on, I would like to trigger my Jenkins build job when that branch is created from master (it will not be modified).
The issue: when I do the configuration of the Jenkins it automatically triggers job for all my previous release branches which is NOT what I want. How to tell Jenkins "start from now on" for every new release branch?
Configuration:
Discover branches:
Exclude branches that are also filed as PRs
Discover pull requests from origin:
Merging the pull request with the current target branch revision
Filter by name (with wildcards):
Include:
release/*
Thanks a lot!!!
Related
I have recently started to experiment code review using Gerrit Code Review. Now I am trying to create a pipeline in jenkins and I have some issues with building based on a specific branch.
This is what I want to obtain:
I have 2 remote branches: master and develop.
For each new feature I create a local branch and I use git push origin HEAD:refs/for/develop to send the changes to review in order to be eventually merged into the remote's develop branch.
After the changes are accepted and the merge is finalized the code from the develop branch should be built and the result will be deployed to server_1.
At some point the develop branch will be merged into the master branch. The code from the master branch will be built and the result will be deployed to server_2.
I have managed to use Patchset Created event to start the build for the changes that are being reviewed. And probably I will use Change Merged event to start the build based on the develop branch after the changes have been merged
I made the following settings:
Refspec: $GERRIT_REFSPEC:$GERRIT_REFSPEC
Branches to build: $GERRIT_REFSPEC
disabled Lightweight checkout
I tried to use the Ref Updated event to start the build when I push a commit directly into the develop from the local develop branch but it results in a failure. Why is this happening? What settings should I make to make it work?
Also how do I deploy code to the right server based on the current branch name?
Context
I have a BitBucket repo and a Bamboo Plan. The Bamboo Plan is tied to the Bitbucket repo in the "Repository" settings.
The Bamboo Plan "Branch" settings are set to create a new Branch when a new branch is created in the repo.
Issue
When I create a branch, bamboo makes a new branch and starts the build. The first build is tied to the latest commit which came from the original branch. I don't want to associate the new branch build with a commit to the original branch. (It causes more than one build to be associated with the commit.)
Desired Outcome
The build should only tie to new commits in the branch.
Solutions
Pull Request Trigger
I modified my bamboo plan to only trigger new bamboo branches when a Pull Request is created for the repo branch. It did give me the desired outcome. The downside is that commits to the branch will not be executed against the CICD process until a PR is created.
Is there a way to create Bamboo branches only on the first commit to a new repo branch?
No.
I'm sorry there isn't much you can do about this.
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 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.
I am using the "inverse" build strategy. When we do a merge from feature branch to development branch, then from development branch to release branch. We can see Jenkins did see the changes in the branch, but started only one build. It's not starting the build for origin/REL-Sprint1606. There is line shows Label=[origin/REL-Sprint1606]
Checking out Revision b81dd73053889e753b41565a4ecec99c081eb1b0 (origin/development, origin/REL-Sprint1606)
Regular expression run condition: Expression=[.*\/[dD][eE][vV].*], Label=[origin/development ]
I found this bug report to Jenkins, but it's closed now:
Git plugin only triggers a build for one branch
https://issues.jenkins-ci.org/browse/JENKINS-11337