We have a lot of developers creating feature branches that I would like to build. Nightly we run a code quality tool that needs to run on every branch. I also would not like a static configuration because the number of branches changes every few weeks.
When you are interested in using a job to build multiple branches, you can choose how Jenkins chooses the branches to build and the order they should be built. This extension point in Jenkins is used by many other plugins to control the job as it builds specific commits.
In this scenario, on every change of integration, Jenkins will perform a merge with the master branch, and try to perform a build if the merge is successful. It then may push the merge back to the remote repository if the Git Push post-build action is selected.
Was needed when using Git within the Multi SCM plugin. Pipeline is the robust and feature-rich way to checkout from multiple repositories in a single job. An experiment was created many years ago that attempted to create combinations of submodules within the Jenkins job.
This extension point in Jenkins is used by many other plugins to control the job as it builds specific commits. When you activate those plugins, you may see them installing a custom build strategy. The maximum age of a commit (in days) for it to be built.
In Git configuration there is a field 'Branch Specifier (blank for default): ' if you put there ** it will build all branches from all remotes.
having that you can use an environment variable ${GIT_BRANCH} e.g. to set a title for the build using https://wiki.jenkins-ci.org/display/JENKINS/Build+Name+Setter+Plugin or for other purposes
I had the same problem to be solved. Specifically, make a zip file of all branches and offer those as artifacts to be used in different test jobs.
In "Branches to build", put "**"
Then, Execute shell:
while read -ra ITEM; do for i in "${ITEM[@]}"; do git checkout $i <do your stuff> done done <<< $(git branch -r | grep -v "HEAD ->" | xargs -L 1 | cut -d'/' -f2)
This reads the list of branches, checkouts each of them separately and allows to do stuff in each of them. The <<< command converts this output:
origin/HEAD -> origin/master origin/branch1 origin/master origin/secondbranch
into checkout usable list:
branch1 master secondbranch
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With