Jose Luis
Jose Luis

Reputation: 3363

Make a jenkins build with conditional per branch parameter

I currently have a jenkins job that builds my project from the develop branch. We follow a modified gitflow because of some technical constraints.

Anyway, basically what I want to do is to add a string parameter that takes a tagname and deploys from refs/tags/${tagname} tagname is of course the parameter. I want to make this parameter optional so that when this parameter is empty I build the development branch (not the tag).

One solution is duplicating this build job and making the configuration for the deployment with a parameter but I want to know if there is a way of modifying this job to make a build according to a tag (so a branch different than the develop branch)

I've tried looking everywhere but can't find any information on how to introduce an optional branch build according to a parameter in the source code management section of jenkins. I am checking multibranch pipeline configution currently...

Upvotes: 1

Views: 1574

Answers (2)

fsinisi90
fsinisi90

Reputation: 1158

You can use a Conditional step with the Strings match condition and use the GIT_BRANCH variable.

Jenkins conditional step by branch name

Upvotes: 1

Ashokekumar S
Ashokekumar S

Reputation: 361

We had a similar situation and for various reasons we did create two jobs (some job configs were also specific to TAG) & we had a parent job which would trigger the respective child job based on the input parameter, in this case your TAG name as param can decide which child job to be invoked

Upvotes: 0

Related Questions