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.
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. Latest Jenkins docs say that GET is depreciated for security reasons, so POST should be preferred.
Create a remote Jenkins build trigger in three stepsCreate a Jenkins build job and enable the Trigger builds remotely checkbox. Provide an authentication token; This can be any text string of your choice. Invoke the Jenkins build URL to remotely trigger the build job.
Configure a job to trigger from remote in Jenkins You can create a new FreeStyle job or you can use the previous one. Move to configuration -> Build Triggers sections and check the “Trigger builds remotely(e.g., from scripts)” option and paste the token name there.
Install Generic Webhook Trigger plugin. Select generic webhook trigger in build trigger actions. Generate a random string and paste in token. Now your job can be triggered with a http request to the following url.
See Jenkins documentation: Parameterized Build
Below is the line you are interested in:
http://server/job/myjob/buildWithParameters?token=TOKEN&PARAMETER=Value
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