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

 java -jar jenkins-cli.jar -s 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$JOB_NAME/buildWithParameters

– Build with parameters with default values

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

– Normal build


3. Using Jenkins User token

curl --user $USER_NAME:$TOKEN$JOB_NAME/build

Leave a Reply

Your email address will not be published.