Invoke jenkins by command

1. Automatically start the jenkins job:

Start the job with no arguments:

curl --user USER:PASSWORD  JENKINS_URL/job/JOBNAME/build

Start the job with parameters:

curl --user USER:PASSWORD  JENKINS_URL/job/JOBNAME/buildWithParameters

2, Automatically disable Project:

curl   --user ${UserName}:${PASSWORD} -o /dev/null --data disable JENKINS_URL/job/JOBNAME/disable

3. Query the status of the job

curl --silent ${JENKINS_SERVER}/job/JOB_NAME/lastBuild/api/json

4. Get the num of the build

curl --silent ${JENKINS_SERVER}/job/JOB_NAME/lastBuild/buildNumber


5. Get the num of the most recent successful build

curl --silent ${JENKINS_SERVER}/job/JOB_NAME/lastStableBuild/buildNumber


You can use shell commands directly


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324930855&siteId=291194637