Jenkins – One job for all branches or One job per branch?
What is the best practice to automate build with Jenkins? I could have one Jenkins job and use the
$GIT_BRANCH variable to make some decision on workflow. Or I could have one Jenkins job per branch (eg. one Jenkins job for master branch and another for develop branch).
What is the best practice?
One Solution collect form web for “Jenkins – One job for all branches or One job per branch?”
It depends. Choose the variable method if:
- The difference in behavior is minimal
- There are a lot of branches
- There are downstream jobs which also depend on the branch variable
Choose the one per job method if any of those previous reasons are false, or you need to deploy differently on each branch, simultaneously (like all branches have code changes at the same time).
In general, I would recommend using the environment variable and making a parametrized job. If you still want to make multiple jobs, I recommend using matrix jobs to track the many different dimensions you may build on.