Jenkins

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/OptionExampleDescription
jenkins-cli.jar -s helpjava -jar jenkins-cli.jar -s http://localhost:8080 helpDisplay available commands
jenkins-cli.jar -s who-am-ijava -jar jenkins-cli.jar -s http://localhost:8080 who-am-iDisplay the current user details

Managing Jobs #

Command/OptionExampleDescription
create-jobjava -jar jenkins-cli.jar -s http://localhost:8080 create-job my-job < config.xmlCreate a new job from an XML file
delete-jobjava -jar jenkins-cli.jar -s http://localhost:8080 delete-job my-jobDelete a job
buildjava -jar jenkins-cli.jar -s http://localhost:8080 build my-jobTrigger a build for a job
disable-jobjava -jar jenkins-cli.jar -s http://localhost:8080 disable-job my-jobDisable a job
enable-jobjava -jar jenkins-cli.jar -s http://localhost:8080 enable-job my-jobEnable a job
copy-jobjava -jar jenkins-cli.jar -s http://localhost:8080 copy-job old-job new-jobCopy a job
get-jobjava -jar jenkins-cli.jar -s http://localhost:8080 get-job my-jobRetrieve the XML configuration of a job
update-jobjava -jar jenkins-cli.jar -s http://localhost:8080 update-job my-job < config.xmlUpdate a job with a new XML configuration

Managing Builds #

Command/OptionExampleDescription
console-outputjava -jar jenkins-cli.jar -s http://localhost:8080 console-output my-jobRetrieve the console output of the last build
list-buildsjava -jar jenkins-cli.jar -s http://localhost:8080 list-builds my-jobList all builds for a job
stop-buildjava -jar jenkins-cli.jar -s http://localhost:8080 stop-build my-job <build_number>Stop a running build

Managing Plugins #

Command/OptionExampleDescription
install-pluginjava -jar jenkins-cli.jar -s http://localhost:8080 install-plugin gitInstall a plugin
list-pluginsjava -jar jenkins-cli.jar -s http://localhost:8080 list-pluginsList all installed plugins
uninstall-pluginjava -jar jenkins-cli.jar -s http://localhost:8080 uninstall-plugin gitUninstall a plugin

User Management #

Command/OptionExampleDescription
create-userjava -jar jenkins-cli.jar -s http://localhost:8080 create-user --username user --password pass --fullname "User Name" --email user@example.comCreate a new user
delete-userjava -jar jenkins-cli.jar -s http://localhost:8080 delete-user userDelete a user

System Configuration #

Command/OptionExampleDescription
reload-configurationjava -jar jenkins-cli.jar -s http://localhost:8080 reload-configurationReload the Jenkins configuration from disk
safe-restartjava -jar jenkins-cli.jar -s http://localhost:8080 safe-restartRestart Jenkins after all running jobs have completed
safe-shutdownjava -jar jenkins-cli.jar -s http://localhost:8080 safe-shutdownShutdown 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.

Jenkins

Explore our comprehensive cheatsheets to enhance your knowledge and efficiency. Each cheatsheet provides detailed command options, examples, and descriptions to help you master various tools and technologies.