Enable Jenkins CLI across all controllers

Issue

Environment

  • CloudBees Jenkins Operations Center
  • Private Saas Edition

Resolution

Please make sure that all Jenkins controllers 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 controllers:

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 controller:

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 controller restarting
  File file = new File(groovyFile)
  file.delete()
} catch (all) {
  println "Unable to delete '$groovyFile'. " +
          "If controller 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 controllers.

Have more questions?

0 Comments

Please sign in to leave a comment.