Jenkins – Trigger builds remotely

Posted by

There are different ways in which remote Jenkins build can be triggered,here below are some options.

1. Using Jenkins CLI (Command Line Interface) Library

– Download Jenkins CLI Library jenkins-cli.jar https://drive.google.com/open?id=0Bw3J992vRA_DMU52eHA3Xy1PR0U

 java -jar jenkins-cli.jar -s http://remotejenkins.com build '$JOB_NAME' --username $USER_NAME --password $PASSWORD

2. Using CURL

– Build with parameters with custom values

curl -XPOST --silent --show-error --user $USER_NAME:$PASSWORD http://remotejenkins.com/job/$JOB_NAME/buildWithParameters

– Build with parameters with default values

curl -XPOST --silent --show-error --user $USER_NAME:$PASSWORD http://remotejenkins.com/job/$JOB_NAME/buildWithParameters?$PARAM_NAME1=$PARAM_VALUE1&$PARAM_NAME2=$PARAM_VALUE2

– Normal build

curl -X POST http://remotejenkins.com/job/$JOBNAME/build --user $USER_NAME:$PASSWORD

3. Using Jenkins User token

curl --user $USER_NAME:$TOKEN http://remotejenkins.com/job/$JOB_NAME/build

Leave a Reply

Your email address will not be published.