Use Jenkins CLI build tasks

Jenkins provides users with a variety of ways to build tasks.
In addition to the Web interface and REST API, you can also create a task from the command line, delete, building and so on.
Official wiki: https: //jenkins.io/doc/book/managing/cli

Jenkins Jenkins allow clients to connect the server through the HTTP protocol or the SSH protocol.

Preparation:
Download jenkins-cli.jar, address: JENKINS_URL / jnlpJars / jenkins-cli.jar , which JENKINS_URL is JENKINS address.
Connecting through HTTP User ID and API Token requires

# Get list of tasks
java -jar jenkins-cli.jar -s jenkinsurl -auth User ID: APIToken list-jobs

# Obtain job details
java -jar jenkins-cli.jar -s jenkinsurl -auth User ID: APIToken get-job JobName

#构建任务
java -jar jenkins-cli.jar -s jenkinsurl -auth User ID:APIToken build JobName -p tag=1.0.1.20190813_release -p giturl=giturl -f

Published 33 original articles · won praise 0 · Views 3923

Guess you like

Origin blog.csdn.net/erhaiou2008/article/details/103974283