Created
July 6, 2018 17:34
-
-
Save brandon-fryslie/d1eba2730914c9af9f486b73961ac794 to your computer and use it in GitHub Desktop.
config remote trigger plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jenkins.model.* | |
import org.jenkinsci.plugins.ParameterizedRemoteTrigger.* | |
import net.sf.json.JSONObject | |
if (System.env.REMOTE_JENKINS_URL) { | |
println "Configuring remote Jenkins instances" | |
def remoteJenkinsUrls = System.env.REMOTE_JENKINS_URL.split(',') | |
def remoteJenkinsNames = System.env.REMOTE_JENKINS_NAME.split(',') | |
def authMode = new JSONObject() | |
authMode.value = 'none' | |
def auth = new JSONObject() | |
auth.authenticationMode = authMode | |
def remoteBuildConfig = Jenkins.instance.getDescriptor(RemoteBuildConfiguration.class) | |
def remoteServers = [] | |
remoteJenkinsUrls.eachWithIndex { url, index -> | |
remoteServers << new RemoteJenkinsServer(url, remoteJenkinsNames[index], false, auth) | |
} | |
remoteBuildConfig.remoteSites = remoteServers | |
remoteBuildConfig.save() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment