I have a parameterised jenkins job that is accessing my plugin. Inside plugin's code in java, i require these parameters using which i have to trigger another job in jenkins. I am not able to fetch these parameters and it is a very high priority issue now. I ahve tried multiple solutions available on stackoverflow, for eg., tried accessing the environment variables but didn't received the param's value. for e.g., my parameter is 'REPOS' and i need its value, i have tried :
System.getProperty("REPOS");
but it returns null.
Also, tried :
Map<String, String> env = System.getenv();
for (String envName : env.keySet()) {
System.out.format("%s=%s%n", envName, env.get(envName));
}
but it prints the jenkins' environment variables and not the job's parameters.
I am referring to the value passed in the text box beside param: "url" in the below picture.

Please assist.
Thanks for the suggestions, but it worked when i did the following: I hit the
JENKINS_HOST_URL/job/JENKINS_SEED_JOB_NAME/api/json?pretty=true
and found the current build number, thereafter, hitting jenkins again with this number(JENKINS_HOST_URL/job/JENKINS_SEED_JOB_NAME/currBuildNum/api/json?pretty=true),
I was able to fetch all the parameters passed in there in this build.
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