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?

  • Revert commit on remote branch without force pushing
  • AppVeyor - Deploy only when is a tag in an specific branch
  • ASP.NET: Securing Config Files in Github
  • Setting up Continuous integration and continuous deployment for Microsoft Applications
  • Continuous deployment of OSGi-based application on jenkins
  • How to deploy to Heroku directly from my Gitlab repository
  • Git: Undo local changes; git add . + git rm?
  • Is it possible to 'colorize' git log messages?
  • Someone sent me a pull request, what do I do?
  • git merge local with remote master using terminal
  • Cannot push changes to repository (GIT)
  • Append git's branch name to command prompt
  • 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.

    Git Baby is a git and github fan, let's start git clone.