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
One of the option to achieve this is "PASS and GET AS ARGUMENT" in your java code.
Jenkins's variables value can be retrieved like this.
urlValue=${url}
Then pass this value in java code. This will be structure of your Execute shell in job configuration.
#!/bin/bash -e
urlValue=${url}
# run java code
java <classNameToRun> $urlValue
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.
To the best of my knowledge, Jenkins parameters are exposed as environment variables. However, if you use a build system like Maven that launches Java sub-processes, those variables might not be inherited.
Probably your most reliable approach is to explicitly pass parameters as system properties in your Jenkins configuration, eg -DREPOS=${REPOS}