I am invoking a Jenkins job remotely using:
wget http://<ServerIP>:8080/job/Test-Jenkins/build?token=DOIT
Here Test-Jenkins
job is invoked and DOIT
is the security token that I have used.
Now I need to pass some parameters to the build.xml file of this job i.e. Test-Jenkins
.
I have not yet figured out how to pass the variables yet.
You can simply try it with a jenkinsfile. Create a Jenkins job with following pipeline script.
Build the job once manually to get it configured & just create a http POST request to the Jenkins job as follows.
The format is
http://server/job/myjob/buildWithParameters?PARAMETER=Value
To trigger a build with own/custom parameters, invoke the following URL (using either POST or GET):
Then in your Jenkins job configuration, tick the box named "
This build is parameterized
", click the "Add Parameter
" button and select the "String Parameter
" drop down value.Now define your parameter - example:
Now you can use your parameter in your job / build pipeline, example:
See Jenkins documentation: Parameterized Build
Below is the line you are interested in:
To pass/use the variables, first create parameters in the configure section of Jenkins. Parameters that you use can be of type text, String, file, etc.
After creating them, use the variable reference in the fields you want to.
For example: I have configured/created two variables for
Email-subject
andEmail-recipentList
, and I have used their reference in theEMail-ext
plugin (attached screenshot).