Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save brandon-fryslie/d1eba2730914c9af9f486b73961ac794 to your computer and use it in GitHub Desktop.
Save brandon-fryslie/d1eba2730914c9af9f486b73961ac794 to your computer and use it in GitHub Desktop.
config remote trigger plugin
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