Jenkins Cheatsheet
#
Jenkins is an open-source automation server written in Java. It is used to automate parts of the software development process, including building, testing, and deploying applications. Jenkins supports a wide range of plugins to integrate with various development, deployment, and testing technologies.
Jenkins CLI Basics
#
Command/Option | Example | Description |
---|
jenkins-cli.jar -s help | java -jar jenkins-cli.jar -s http://localhost:8080 help | Display available commands |
jenkins-cli.jar -s who-am-i | java -jar jenkins-cli.jar -s http://localhost:8080 who-am-i | Display the current user details |
Managing Jobs
#
Command/Option | Example | Description |
---|
create-job | java -jar jenkins-cli.jar -s http://localhost:8080 create-job my-job < config.xml | Create a new job from an XML file |
delete-job | java -jar jenkins-cli.jar -s http://localhost:8080 delete-job my-job | Delete a job |
build | java -jar jenkins-cli.jar -s http://localhost:8080 build my-job | Trigger a build for a job |
disable-job | java -jar jenkins-cli.jar -s http://localhost:8080 disable-job my-job | Disable a job |
enable-job | java -jar jenkins-cli.jar -s http://localhost:8080 enable-job my-job | Enable a job |
copy-job | java -jar jenkins-cli.jar -s http://localhost:8080 copy-job old-job new-job | Copy a job |
get-job | java -jar jenkins-cli.jar -s http://localhost:8080 get-job my-job | Retrieve the XML configuration of a job |
update-job | java -jar jenkins-cli.jar -s http://localhost:8080 update-job my-job < config.xml | Update a job with a new XML configuration |
Managing Builds
#
Command/Option | Example | Description |
---|
console-output | java -jar jenkins-cli.jar -s http://localhost:8080 console-output my-job | Retrieve the console output of the last build |
list-builds | java -jar jenkins-cli.jar -s http://localhost:8080 list-builds my-job | List all builds for a job |
stop-build | java -jar jenkins-cli.jar -s http://localhost:8080 stop-build my-job <build_number> | Stop a running build |
Managing Plugins
#
Command/Option | Example | Description |
---|
install-plugin | java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin git | Install a plugin |
list-plugins | java -jar jenkins-cli.jar -s http://localhost:8080 list-plugins | List all installed plugins |
uninstall-plugin | java -jar jenkins-cli.jar -s http://localhost:8080 uninstall-plugin git | Uninstall a plugin |
User Management
#
Command/Option | Example | Description |
---|
create-user | java -jar jenkins-cli.jar -s http://localhost:8080 create-user --username user --password pass --fullname "User Name" --email user@example.com | Create a new user |
delete-user | java -jar jenkins-cli.jar -s http://localhost:8080 delete-user user | Delete a user |
System Configuration
#
Command/Option | Example | Description |
---|
reload-configuration | java -jar jenkins-cli.jar -s http://localhost:8080 reload-configuration | Reload the Jenkins configuration from disk |
safe-restart | java -jar jenkins-cli.jar -s http://localhost:8080 safe-restart | Restart Jenkins after all running jobs have completed |
safe-shutdown | java -jar jenkins-cli.jar -s http://localhost:8080 safe-shutdown | Shutdown Jenkins after all running jobs have completed |
This cheatsheet covers the most commonly used Jenkins CLI commands and options, helping you to manage jobs, builds, plugins, users, and system configurations effectively.