-
-
Save Buzer/5148372464e2481a797091682fabbad5 to your computer and use it in GitHub Desktop.
This file contains 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
Jenkins.instance.getInjector().getInstance(AdminWhitelistRule.class).setMasterKillSwitch(false) | |
def store = Jenkins.instance.getExtensionList("com.cloudbees.plugins.credentials.SystemCredentialsProvider")[0].getStore() | |
def ghspec = new ArrayList<DomainSpecification>() | |
ghspec.add(new HostnameSpecification("api.github.com", "")) | |
def ghdomain = new Domain("api.github.com", "GitHub", ghspec) | |
ghuserpasscreds = new UsernamePasswordCredentialsImpl( | |
CredentialsScope.GLOBAL, | |
"ghuserpass", "GitHub username & password", | |
ghcreds.username, | |
ghcreds.password | |
) | |
ghtokencred = new StringCredentialsImpl( | |
CredentialsScope.GLOBAL, | |
"ghtoken", | |
"GitHub token", | |
Secret.fromString(ghcreds.token) | |
) | |
store.addCredentials(ghdomain, ghtokencred) | |
store.addCredentials(Domain.global(), ghuserpasscreds) | |
def jobName = "foobar" | |
def configXml = new File("/etc/jenkins/jobs/githuborgs/foobar.xml").text.trim() | |
def xmlStream = new ByteArrayInputStream(configXml.getBytes()) | |
Jenkins.instance.createProjectFromXML(jobName, xmlStream) | |
Jenkins.instance.getJob(jobName).scheduleBuild(5, new hudson.model.Cause.RemoteCause("localhost", "Inital refresh")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment