Jump to content

Jenkins and Parametrized Branch Names

Posted on:October 8, 2018 at 02:00 AM

The Problem

In one of the projects we work at Gemotial it was pretty cumbersome to test feature branches locally. The changes very often could have an impact on MSSQL or Oracle backend. We thought it would be great if we cloud run the changes on our integration tests configuration in Jenkins. Then, use the tests results (a link to it) in merge-request description. That way we could ensure that new functionality does not break the software.

The only problem was in Jenkins we had hardcoded branch name in the build configuration.

The Solution

It turned out Open Source folks have already thought about it. Jenkins configuration build can be parametrized. In project configuration Source Code Management we need to specify the branch as a variable.

Then we have to tick Project is parametrized checkbox and specify parameter name and its default value.

After configuring the build and triggering it you should see a prompt asking for branch name like below:

This is an excellent solution to test out changes. Just remember to push the branch to the repository.

One missing configuration

Although we are happy with our new way of work, we are not 100% satisfied. As a next step, we would like Jenkins to automatically update specific merge-request with build status. That way we would have automated the whole process. This is the ultimate goal.


Jenkins provides a pretty nice and simple way to customize your development process. This way we could decrease the number of integration issues and automate one more thing.