diff --git a/casc-update-master-path.groovy b/casc-update-master-path.groovy new file mode 100644 index 0000000..8d1f109 --- /dev/null +++ b/casc-update-master-path.groovy @@ -0,0 +1,24 @@ +//only runs on CJOC + +import com.cloudbees.opscenter.server.casc.BundleStorage +import hudson.ExtensionList + +String masterName = "master1" +String masterPath = "folder1/master1" +boolean regenerateBundleToken = false + +setBundleConfig(masterName, masterPath, regenerateBundleToken) + +// set the masterPath for a master, and optionally regenerate the bundle token +private static void setBundleConfig(String masterName, String masterPath, boolean regenerateBundleToken) { + sleep(100) + ExtensionList.lookupSingleton(BundleStorage.class).initialize() + BundleStorage.AccessControl accessControl = ExtensionList.lookupSingleton(BundleStorage.class).getAccessControl() + accessControl.updateMasterPath(masterName, masterPath) + if (regenerateBundleToken) { + accessControl.regenerate(masterName) + } +} + + +