Here is the solution that worked best for me:

I have a project that builds a set of tools that I use across multiple 
builds.  Before moving to pipeline, it includes build utilities, build 
scripts, stuff like that.

When I moved to Pipeline, I now build that project from Git, and then in my 
other projects, I have a bootstrap Jenkins file that basically does the 
following steps within a node() {}:
-  checkout scm
-  Copy artifacts from build utilities project
-  load 'buildutilties/topLevelBuild.groovy'
-  topLevelBuild.build()

In my "topLevelBuild.groovy" file, I define all of my common build steps, 
and I use the build() as the main entry point. 

For the artifact copy, you can use a selector to determine which version of 
the build utilities you want to copy over.

With this strategy, I can change all of my builds by just checking in a new 
version of topLevelBuild.groovy, letting that rebuild, and then the other 
projects just pick it up.

Cheers,
Greg


On Wednesday, July 20, 2016 at 1:24:46 PM UTC-4, Marco Pas wrote:
>
> We just took to step to move our CI environment to Jenkins 2. We see that 
> we are creating the same build over and over. The jenkinsfile is great, but 
> now we see that we need to repeat it in every project. At the end that 
> becomes it maintenance nightmare..
>
> We have multiple git projects that are equal in structure and need to be 
> build in the same way.
>
> Example:
> gitrepo - App1 - Jenkinsfile (MultiBranchPipeline)
> gitrepo - App2 - Jenkinsfile (MultiBranchPipeline)
> gitrepo - App3 - Jenkinsfile (MultiBranchPipeline)
> ....
>
> We are actually coping the same Jenkinsfile to these projects and if we 
> need a change we need to adapt all of them. So this becomes a nightmare.
>
> Is there a better way of organizing this and getting a repeatable way of 
> doing things?
>
> - Marco
>

-- 
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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/18008772-04ac-4469-aed7-83613fb1dd72%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to