This section provides common examples of usage. Be sure to replace operations-center-url
with the URL of the operations center.
Listing all available Jenkins CLI tool commands
Type the following command to list all available Jenkins CLI tool commands:
java -jar jenkins-cli.jar -s https://operations-center-url:8888/ help
which outputs a list of commands followed by indented descriptions, such as
add-job-to-view Adds jobs to view. ...
Authenticating Jenkins users using the Jenkins CLI tool
To authenticate your Jenkins user when using the Jenkins CLI tool, specify the -auth
option with your username and API token in the format username:apiToken
.
For example, enter the command:
java -jar jenkins-cli.jar -auth username:apiToken -s https://operations-center-url:8888/ version
The resulting output contains a version number:
2.375.3.5
Many Jenkins CLI commands require an authenticated Jenkins user with appropriate permissions, such as the Administer permission. For more on permissions in CloudBees CI, see Restricting access and delegating administration with Role-Based Access Control in CloudBees CI on modern cloud platforms. |
Obtaining information about Jenkins CLI tool commands
To obtain more information about a particular Jenkins CLI command, specify help
followed by the command itself.
For example, to obtain more information about the plugin-catalog
command, enter the command:
java -jar jenkins-cli.jar -auth username:apiToken -s https://operations-center-url:8888/ help plugin-catalog
and the following output is displayed:
java -jar jenkins-cli.jar plugin-catalog [VAL] [--delete VAL] [--master VAL] [--push VAL] [--put] [--remove VAL] Plugin Catalog Management VAL : Use a catalog name to get its metadata content. A list of catalog names is returned by calling the command without any parameter. plugin-catalog plugin-catalog my-plugin-catalog --delete VAL : Use this option to delete a catalog from the available list, whose name is passed as parameter. --delete my-plugin-catalog --master VAL : Master item full name (including folders and white spaces, which needs double quotes). Use it in tandem with --push to select the master to push the catalog to. --master my-master --push my-plugin-catalog --push VAL : This option pushes a catalog to a master. Use it in tandem with --master to select the master to apply the catalog to. --master my-master --push my-plugin-catalog --put : Create or update a catalog. It will not be applied to any master, just added to the catalog management. --put < my-plugin-catalog.json --remove VAL : Removes the current catalog from a master. The catalog will not be deleted from the available list. --remove my-master-with-a-plugin-catalog