Do multibranch jobs lead to code duplication?

16 views
Skip to first unread message

Martin Schmude

unread,
Jul 21, 2020, 5:37:39 PM7/21/20
to Jenkins Users
Dear all,

if I understand multibranch jobs right, then a Jenkinsfile in branch "master" will be replicated into all other branches drawn from "master".
It has to be like that because the Jenkinsfile is the "marker" that tells Jenkins to build a branch, and how to do that. Branches without a Jenkinsfile will not be built.

This will often result in code duplication, with all the well-known issues.
If a small change has to be made to the Jenkinsfile, it has to be applied to all branches.

How do you handle that issue? Is there a recommended practice?

jeremy mordkoff

unread,
Jul 22, 2020, 11:58:43 AM7/22/20
to Jenkins Users
How do you normally handle branches and merging? I use the same tools and branching and merging rules as the rest of the team, i.e. development and QA. 

In our case, the teams are required to merge from master to their project branches on a regular basis, so they will eventually get my changes that I make in master.

Nick Stolwijk

unread,
Jul 22, 2020, 12:22:51 PM7/22/20
to jenkins...@googlegroups.com
We use the Jenkins pipeline as a library so our Jenkinsfile is as short as:

@Library('Jenkins-pipeline@master')_
def pipelineParams = [
    agent: 'Linux',
    slackChannel: 'build-dev'
]
mavenJavaPipeline pipelineParams

And the real pipeline code is in a separate repository. If you want to change the pipeline you can use a project and change the branch of the pipeline (master -> featurebranch) to test the changes in the library before merging the pipeline changes back to master (effectively adjusting all the builds that use the pipeline).

With regards,

Nick Stolwijk

~~~ Try to leave this world a little better than you found it and, when your turn comes to die, you can die happy in feeling that at any rate you have not wasted your time but have done your best ~~~

Lord Baden-Powell


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/4ceb91fb-e271-4b1f-9026-5154d31e5823o%40googlegroups.com.

Dirk Heinrichs

unread,
Jul 23, 2020, 1:30:51 AM7/23/20
to jenkins...@googlegroups.com
Am Dienstag, den 21.07.2020, 14:37 -0700 schrieb 'Martin Schmude' via Jenkins Users:

If a small change has to be made to the Jenkinsfile, it has to be applied to all branches.

That's true for all code changes which are needed in multiple branches, isn't it? That's called back-/forward porting. It allows your Jenkins job to evolve together with your main code.

HTH...

Dirk
--
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenText ™ Discovery | Recommind
Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach
Vertretungsberechtigte Geschäftsführer Gordon Davies, Madhu Ranganathan, Christian Waida, Registergericht Amtsgericht Bonn, Registernummer HRB 10646
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.

signature.asc
Reply all
Reply to author
Forward
0 new messages