Skip to content

Instantly share code, notes, and snippets.

@frezbo
Forked from kpettijohn/ghprb_auth.groovy
Created June 6, 2017 16:30
Show Gist options
  • Save frezbo/67410eea49aa896e73d12c8525bf45a9 to your computer and use it in GitHub Desktop.
Save frezbo/67410eea49aa896e73d12c8525bf45a9 to your computer and use it in GitHub Desktop.
Configure GitHub Pull Request Builder Jenkins plugin with Groovy
// ghprb 1.29.2
import java.lang.reflect.Field
import jenkins.model.*
import org.jenkinsci.plugins.ghprb.*
def descriptor = Jenkins.instance.getDescriptorByType(org.jenkinsci.plugins.ghprb.GhprbTrigger.DescriptorImpl.class)
Field auth = descriptor.class.getDeclaredField("githubAuth")
auth.setAccessible(true)
githubAuth = new ArrayList<GhprbGitHubAuth>(1)
githubAuth.add(new GhprbGitHubAuth("https://api.github.com", "aebe0886-5ead-47cd-9a13-18490b7a2831", "test1", "d1e9f1cb-c1e0-42f6-b3d9-6ccca25729ab", null))
githubAuth.add(new GhprbGitHubAuth("https://api.github.com", "3ebe0886-5ead-47cd-9a13-18490b7a2831", "test2", "31e9f1cb-c1e0-42f6-b3d9-6ccca25729ab", null))
auth.set(descriptor, githubAuth)
descriptor.save()
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment