We've set up some parameters for executing a build in Jenkins (using the simple "parameterized build" setting). The job is set up as Maven test. Is there a way to programmatically pass those parameters into our Java code? We need to execute certain update functions based on the parameter set via Jenkins.
Yes you can pass your Jenkins parameters to your Java code through the maven execution like this:
mvn clean test -Dparam1=$JOB_PARAM_1
Note that the $JOB_PARAM_1 will capture the value of the parameter set on Jenkins. This is for Unix environments, if you are working with Jenkins on Windows, then use %JOB_PARAM_1% instead.
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