semural
semural

Reputation: 4611

Jenkins Multibranch Pipeline Project vs Pipeline Project

It might be a simple question but what is the main differences between managing multi-branches (dev-test-master) using declarative pipeline in Pipeline project and select Multibranch pipeline project?

I would like to deploy my application to the Kubernetes environment according to the branch variable. Which project type should I use to follow best practices or which one is easy to manage? I guess I can do the same thing and manage my branches and deployment environment only one Jenkinsfile in Pipeline project.

Upvotes: 0

Views: 2321

Answers (1)

MaratC
MaratC

Reputation: 6869

With Multibranch, you get one Jenkinsfile per branch. Without it, you don't. That's the main difference.

With file per branch, you can have separate instructions on how exactly to build this branch (the "configuration as a code" notion). E.g. if you have 5 containers, you may have five "Build Container X" stages (maybe run in parallel) and five "Test Container X" stages (ditto). In your new branch you develop a new container, so in that branch's Jenkinsfile you may now have six build and six test stages instead of five. Now, under source control, any branch that descends from the regular branch(es) will inherit its Jenkinsfile (and build/test 5 containers) while any branch over this new branch will inherit that Jenkinsfile (and build/test 6 containers) without any need to change a thing.

With one Jenkinsfile, this may quickly get convoluted.

This is completely orthogonal to the branch variable that you may check and act on it differently. In our environment, we have both: a Jenkinsfile per branch, and checking the branch variable inside all Jenkinsfiles. This minimizes the merge effort.

Upvotes: 2

Related Questions