Reputation: 911
I try to execute multiple stages within a jenkins pipeline with maven. In the moment every step within the steps block within a stage is wrapped with withMaven( ... )
. The needed mavenOpts and the local maven repo stays the same throughout the whole jenkins pipeline, so I wondered if it's possible to configure the maven pipeline integration plugin at the beginning of this pipeline so I don't need to wrap every single step with the same withMaven()
wrapper.
Upvotes: 2
Views: 745
Reputation: 1056
You could write a shared-library method that accepts a string, and performs a withMaven upon it. Then, from the Jenkinsfile, invoke the shared-library method from each step that needs it. That will encapsulate a bunch of maven-configuration stuff inside the centralized shared-lib.
Upvotes: 2