Essentially I want my Jenkinsfile to look something like this:
@Library('my-descriptive-pipline') _
myPipeline('arg1','arg2','arg3')
Then my shared library (/vars/descriptivePipeline.groovy) would look like this:
pipeline {
agent any
options {
skipDefaultCheckout()
}
environment {
}
stages {
stage('stageA') {
steps {
... Do something with arg1, arg2 or arg3
}
}
stage('stageB') {
steps {
... Do something with arg1, arg2 or arg3
}
}
....
I want to centralize the pipeline config so I don't have to worry about Jenkinsfile sprawl. Is this possible with declarative pipelines?
Entire Pipelines can now be defined in shared libraries as of Declarative Pipeline 1.2.
You can find more here and here
As the shared libraries plugin documentation states:
Defining Declarative Pipelines
Starting with Declarative 1.2, released in late September, 2017, you can define Declarative Pipelines in your shared libraries as well.
This is fairly new and so there might still be a few bugs around but it should work. Don't forget to upgrade the shared library and declarative plugins though.
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