Created
July 6, 2018 17:33
-
-
Save brandon-fryslie/aa78aa2af085612165be13b9fb423e1b to your computer and use it in GitHub Desktop.
configure 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