Situation: I have a Jenkins pipeline job file with lots of (regularly changing) stages hard-coded with Groovy and I need a way to locally reproduce, what being done on CI.
In order to let the developer locally do, "what Jenkins would do" without having to manually keep a list of steps synchronized with the respective Jenkinsfile I'm looking for a way to store the ordered list of stages accessible by both Jenkins and a local script.
In other words - I want to be able to check out my project repository and run
make what-Jenkins-would-do
(make
is only an example - I really don't want to use make
for this)
So, given a set of scripts which contain what's being executed on each stage I now just need the order of execution stored in a sophisticated way.
What I'd love to have is a way to let Jenkins read a list of pipeline steps from a Yaml/JSON file which then can be used in other scripts, too.
Here is what's going through my mind
- I can't be the only one - there must be a tiny nice solution for this need
- maybe I could use Groovy locally, but that would add another heavy dependency to my project and the Groovy-scripts contain lot's of Jenkins- and node-specific stuff I don't need locally
- Don't want to store information redundantly
- Just executing a 'do it all' script in both Jenkins and locally is not an option of course - I need individual stages.
- Jenkins / Groovy and pipeline jobs are a requirement - I can't change that
So what's the modern solution to this? Is there something like
node('main') {
stage('checkout') {
// make the source code available
}
stages_from_file("build-stages.yaml")
}
?