Enable Jenkins CLI Across All Masters



  • CloudBees Jenkins Operations Center
  • Private Saas Edition


Please make sure that all Jenkins masters are connected to your CloudBees Jenkins Operations Center.

Click “New Item”:

Next click on Cluster Operation:

Under the Operation center configuration screen select Add Operation and select Managed Masters:

Then select From Operations Center Root and under the Filters select Is Online:

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

Then paste the following:

import java.nio.file.Files
import java.nio.file.Paths

def env = System.getenv()
def jhome = env['JENKINS_HOME']
def initDir = "$jhome/init.groovy.d"
def initDirPath = Paths.get(initDir)
def groovyFile = "$initDir/cli-shutdown.groovy"

try {
  // Delete file that disable CLI protocols
  // get enabled upon Jenkins master restarting
  File file = new File(groovyFile)
} catch (all) {
  println "Unable to delete '$groovyFile'. " +
          "If master restarts, must apply this script again"

Then click Save.
Finally execute the cluster operation by clicking run:

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

Have more questions?


Please sign in to leave a comment.