Prerequisite:
- Ubuntu OS
- Java installed. You can use jabba to install specific version
Basics of using Jenkins CLI:
- Jenkins CLI documentation can be accessed through the following URL address:
http://[jenkins_url]:8080/cli
- To use Jenkins CLI you can download the executable jar file from the following URL address:
http://[jenkins_url]:8080/jnlpJars/jenkins-cli.jar
- To authenticate Jenkins CLI commands against the server you can create a token or use an existing one. The token is generated at:
http://[jenkins_url]:8080/user/[username]/configure
or via User profile --> Configure: - To list existing Jenkins jobs use the following command:
java -jar jenkins-cli.jar -auth [username]:[token] -s http://[jenkins_url]:8080 list-jobs
- To get help on command use:
java -jar jenkins-cli.jar -auth [username]:[token] -s http://[jenkins_url]:8080 help [subcommand]
- To build the job with verbosity mode set use:
java -jar jenkins-cli.jar -auth [username]:[token] -s http://[jenkins_url]:8080 build [job_name] -s -v
- To delete job use:
java -jar jenkins-cli.jar -auth [username]:[token] -s http://[jenkins_url]:8080 delete-job [job_name]
Build-in Jenkins variables:
To get the list of all available built-in Jenkins variables use: https://[jenkins_url]:[port_number]/env-vars.html/