| Declarative stages have become so flexible now: they can have their own options, environment, post stages, agent etc. This makes the ability to reuse and share them even more powerful. My use case is running tests against a selection of specialised hardware, accessible by a generic build agent. In conjunction with the lockable resources plugin, the typical stage for this in the middle of a pipeline looks something like:
stage ('Run tests on kit') {
agent { label 'local-kits' }
options {
lock(label: 'kit-type-1', variable: 'KIT_IP', quantity: 1)
}
steps {
runTest('example-test.zip') // existing shared function to download and run previously archived binary on reserved kit
}
post {
always {
junit 'results.xml'
}
}
}
I use this in a ton of places, and help others include it in their pipelines. If I could replace all that (or maybe just the contents of stage { } ) with a call to a library, it would be really handy. |