Jenkins CLI

To access the Jenkins CLI feature’s page through the operations center interface and download the CLI tool:

  1. Access the Manage Jenkins area
  2. On the Manage Jenkins page, scroll down and click Jenkins CLI
  3. On the Jenkins CLI page, click the jenkins-cli.jar link to download the CLI tool
  4. Move the jenkins-cli.jar file to an appropriate location on your machine’s file system
Generate token for your user:
  1. Go to your user in top right menu
  2. Click Configure
  3. On API Token click on Add new token
  4. Save it for the next commands
Get all possible commands:
java -jar jenkins-cli.jar -s http://127.0.0.1:8080/ --auth admin:11cd450e8f9e3f52cb60ea9d35d0387299 help
List jobs:
java -jar jenkins-cli.jar -s http://127.0.0.1:8080/ -auth admin:11cd450e8f9e3f52cb60ea9d35d0387299 list-jobs
Build Job:
java -jar jenkins-cli.jar -s http://127.0.0.1:8080/ -auth admin:11cd450e8f9e3f52cb60ea9d35d0387299 build test
Restart Jenkins:
java -jar jenkins-cli.jar -s http://127.0.0.1:8080/ -auth admin:11cd450e8f9e3f52cb60ea9d35d0387299 restart
Install/update plugin github-branch-source:
java -jar jenkins-cli.jar -s http://127.0.0.1:8080/ -auth admin:11cd450e8f9e3f52cb60ea9d35d0387299 install-plugin cloudbees-bitbucket-branch-source
Disable plugin:
java -jar jenkins-cli.jar -s http://127.0.0.1:8080/ -auth admin:11cd450e8f9e3f52cb60ea9d35d0387299 disable-plugin github-branch-source