CI/CD
Jenkins CLI Commands
Jenkins CLI commands for build and job management.
28 commands
Windows
MacOS
Linux
#automation
#build
Job Management
List all jobs on the server
java -jar jenkins-cli.jar -s http://localhost:8080 list-jobs
Export job configuration as XML
java -jar jenkins-cli.jar -s http://localhost:8080 get-job my-job
Create a job from XML config
java -jar jenkins-cli.jar -s http://localhost:8080 create-job my-job < config.xml
Delete a job permanently
java -jar jenkins-cli.jar -s http://localhost:8080 delete-job my-job
java -jar jenkins-cli.jar -s http://localhost:8080 copy-job old-job new-job # Copy an existing job to a new name
Enable a disabled job
java -jar jenkins-cli.jar -s http://localhost:8080 enable-job my-job
Disable a job from running
java -jar jenkins-cli.jar -s http://localhost:8080 disable-job my-job
Build Operations
Trigger a build for a job
java -jar jenkins-cli.jar -s http://localhost:8080 build my-job
Trigger a parameterized build
java -jar jenkins-cli.jar -s http://localhost:8080 build my-job -p key=val
Trigger build and wait for completion
java -jar jenkins-cli.jar -s http://localhost:8080 build my-job -s
View console output of build 42
java -jar jenkins-cli.jar -s http://localhost:8080 console my-job 42
Stop all running builds of a job
java -jar jenkins-cli.jar -s http://localhost:8080 stop-builds my-job
Plugin Management
List all installed plugins
java -jar jenkins-cli.jar -s http://localhost:8080 list-plugins
Install a plugin by short name
java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin git
Install plugin and restart Jenkins
java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin git -restart
Restart Jenkins after jobs finish
java -jar jenkins-cli.jar -s http://localhost:8080 safe-restart
Node Management
Export node configuration as XML
java -jar jenkins-cli.jar -s http://localhost:8080 get-node my-node
Create a node from XML config
java -jar jenkins-cli.jar -s http://localhost:8080 create-node my-node < node.xml
Delete a build node
java -jar jenkins-cli.jar -s http://localhost:8080 delete-node my-node
Connect a node and bring it online
java -jar jenkins-cli.jar -s http://localhost:8080 connect-node my-node
Disconnect a node gracefully
java -jar jenkins-cli.jar -s http://localhost:8080 disconnect-node my-node
Mark a node as temporarily offline
java -jar jenkins-cli.jar -s http://localhost:8080 offline-node my-node
Credentials
List credentials in system store
java -jar jenkins-cli.jar -s http://localhost:8080 list-credentials system
Create credentials from XML
java -jar jenkins-cli.jar -s http://localhost:8080 create-credentials-by-xml system < cred.xml
Delete a credential by ID
java -jar jenkins-cli.jar -s http://localhost:8080 delete-credentials system my-cred
Quick Commands
Trigger a build for a specified job on the Jenkins server
java -jar jenkins-cli.jar -s http://localhost:8080 build my-job
List all jobs configured on the Jenkins server
java -jar jenkins-cli.jar -s http://localhost:8080 list-jobs
Install a Jenkins plugin by its short name
java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin git