Reputation: 2321
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.
Upvotes: 2
Views: 10611
Reputation: 780
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.
Upvotes: 9
Reputation: 1
To set the properties, you need to set it using the commandline. For example : export BROWSER =chrome
You can set it in This build is parameterized section of your jenkins build configuration.
you have BROWSER parameter set in jenkins configuration then you can use %BROWSER% in your pom where you need to set the browser.
Upvotes: 0