For example:
I have 30 multibranch Git projects. All projects have their own Jenkinsfile. And suddenly I find a cool Jenkins plugin which I want to add for all projects. This is pain to do it on all projects and this is a big waste of time.
Is it possible to create somethink like template Jenkinsfile which will be something like wrapper for project Jenkinsfile or somethink like that which gives me possibility to do changes in 1 place instead of 30 places?
What I want is something like that:
stage {
...}
timestamps {
<include rest of stages definied in projects>
}
stage {
... }
Template file which is in some repo is looked for like this. All of the projects have their own stages defined which are included in the middle of the template Jenkinsfile and defined in project.
So Jenkinsfile in project must:
You could use:
the Config File Provider Plugin using the configuration files in Jenkins Pipelines:
node {
...
configFileProvider(
[configFile(fileId: 'jenkinsfile-template', ...)]) {
...
}
...
}
load:
Evaluate a Groovy source file into the Pipeline script:
Takes a filename in the workspace and runs it as Groovy source text.
Shared Libraries:
Oftentimes it is useful to share parts of Pipelines between various projects to reduce redundancies and keep code "DRY".
Pipeline has support for creating "Shared Libraries" which can be defined in external source control repositories and loaded into existing Pipelines.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With