Get value from parameterized remote trigger plugin - jenkins

I tried to use parameterized remote trigger plugin to pass value to a remote job following https://github.com/jenkinsci/parameterized-remote-trigger-plugin/blob/master/README_JobConfiguration.md guide. In the upstream job I input a=b into the Parameters field, but in the downstream job in a Execute Windows batch command step, when I tried to get the value using echo %a% the output is empty. How can I get the value of a from downstream job?

You need to make parameterized downstream job having a as parameter. I think you missed this point.

Related

Jenkins - How to pass environmental variable from freestyle job to pipeline job

I have a freestyle job in Jenkins and would normally pass parameters to another freestyle job using the Predefined parameters option.
example:
PROJECT=Myproject
PATH=/depot/workspace/
Previously I could access the above values through the KEY in the downstream job through the environment by using ${PROJECT} OR ${PATH}.
My problem now is that I have a pipeline job that needs to access the above values but when using ${PROJECT} OR ${PATH} it does not work.
So, in general how I want it to work is have the freestyle job run first and pass the parameters to the downstream pipeline job.
You might need to use "${params.PROJECT}" in your pipeline to access the parameters.

trigger parameterized build on other projects does not pass parameter

In a Jenkins pipeline, parameters defined in upstream job is not being passed to downstream job even "current build parameters" option is selected. When I try to echo the parameter value, it is null.
Example: I have checked "This is a parameterized build". There is a string parameter in upstream job called "version" with the default value as "abc". When I run echo $version on the downstream job, in console output I do not see a value being printed.
Environment info:
Jenkins Version: 2.89.3
O/S: CentOs 7
Jenkins installed plugin info:
Build with Parameters: 1.4
Parameterized Trigger plugin:2.35.2
In the downstream job you need to set a variable to accept the parameter being passed.
Example: If foo parameter was passed from upstream job. The downstream should have a parameter (string or one of your choice) same name as foo and default value as $foo.
Finally I found out that the way this parameter works in jenkins 1.x and 2.x versions is different. In the newer version of jenkins, all the down stream projects must be parameterized with the defined parameter and the empty value. However, in Jenkins 1.x was able to pass the parameter from upstream to downstream without defining the parameter in the upstream project. Using only "Current build parameter" was able to do the work but not anymore. Not sure If I am the only one finding it bizarre.

Jenkins predefined parameters and downstream job

I have a question for downstream job in jenkins.
I want to use directly the value of a predefined parameters from upstream job in the git parameter of a downstream job.
How is this done?
Yes , just add the parameters to the downstream job. And it will do the trick

Jenkins build trigger

I used jenkins remote trigger build option at job A and triggered another job B. When I open job B build, I could see "Started by remote project <path to job A>". I am trying to get the value from job B after execution but I not working. I tried working with BuildUser plugin which gave null output. Could someone help me to find a way to find the information?
The Parameterized Remote Trigger Plugin job setup options have a section Build Info with a field Parameters. Define parameters there like:
TRIGGERED_BY_JOB=${JOB_NAME}
TRIGGERED_BY_BUILD_NO=${BUILD_NUMBER}
and use them accordingly in your job B.
See Jenkins Set Environment Variables for other available information.

In Jenkins how to trigger another build job based on the build parameter passed to current build job?

I have build jobs like a-build, a-deploy. b-build, b-deploy.
*-deploy are downstream job for *-build jobs. So they look like,
a-build
|
+-a-deploy
b-build
|
+-b-deploy
Now I have another job X-build. It accepts a-build, b-build etc as a parameter. So I if I run X-build with a-build as parameter it should complete with a post build action that triggers a-deploy. How can that be done?
You can accomplish this quite easily if you receive the job name in a parameter.
You can then use "Call/Trigger Builds on Other Projects" step, and use the Parameter you receive in the job name:
If the step is not available to you via Post Build menu, you can get to it via "Execute set of scripts" post-build step.

Resources