Disable Jenkins CLI across all controllers

Article ID:234942467
3 minute readKnowledge base

Issue

  • I would like to disable the Jenkins CLI across all my controllers.

Resolution

Please make sure that all controllers are online and connected to your operations center.

Create a New Item of type Cluster Operation:

new item cluster op

Under the Operation center configuration screen select Add Operation and select controllers.

Then select From Operations Center Root and under the Filters select Is Online (note that offline controllers will still have the CLI enabled if you add this filter):

cluster op is online

In the Steps section click on Add Step and select Execute Groovy Script on controller:

cluster op groovy script

Then paste the following:

When using High Availability (active/active) replicas, as of product version 2.426.3.3, the groovy script above will only disable the CLI on one of the replicas, to disable the CLI across all replicas, a restart (or rolling restart) of the controllers is required. A forceful restart can be done as part of the cluster operation by using the Restart Now step.

Then click Save.

Finally execute the cluster operation by clicking Run:

run cluster op

This should then run the script on all of the controllers.

If you would like to run this on the CJOC instance as well, then please follow the guide Disable Jenkins CLI.

Known limitations

There are some limitations on the provided script as it will not work as expected in the following cases:

  • 2.276.x and earlier: The script doesn’t disable the SSH port providing access to the CLI via SSH.

  • 2.222.x and earlier: The line including java.lang.Object needs to be removed for it to work. Note that removing this line will result in incomplete protection when applied to newer releases.

  • 2.164.x and earlier: The script doesn’t disable the remoting-based CLI removed in later releases.

  • When using High Availability (active/active) replicas, as of product version 2.426.3.3, the groovy script above will only disable the CLI on one of the replicas, to disable the CLI across all replicas, a restart, or rolling restart of the controllers is required.

Validate if the mitigation script is in place

To validate if the mitigation script is in the correct place, please run this script in the script console of your Operations center, this will run the script across the connected controllers and will return a list with the ones that are not protected.