Issue
-
After applied Disable Jenkins CLI across all controllers I would like to re-enable the Jenkins CLI across all my controllers.
Resolution
Please make sure that all Jenkins controllers are connected to your CloudBees Jenkins Operations Center.
Create a New Item of type 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 jenkins_home = Jenkins.get().getRootDir().absolutePath
def initDirPath = Paths.get(jenkins_home, "init.groovy.d")
def groovyFile = initDirPath.toRealPath().toString() + "/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. Once run, you will need to restart the controller so that the CLI extensions can be loaded again.
Please be aware you might not need to restart to enable CLI through SSH. This can be done anytime in the UI by an admin user under Manage Jenkins → Security.
|