1

I'm trying to configure our Jenkins server via Groovy init scripts. I'm stuck on how to configure the Github Plugin. I want Jenkins to manage my hooks. So I need to add a GitHubServerConfig to the GitHubPluginConfig somehow. I already managed to set up the credentials. So I have this code so far:

import org.jenkinsci.plugins.github.config.GitHubPluginConfig import org.jenkinsci.plugins.github.config.GitHubServerConfig def github = new GitHubPluginConfig() github.setConfigs([ new GitHubServerConfig("github-access-token"), ]) github.save() 

But this doesn't have any affect. Any suggestions?

1
  • Is "github-access-token" the id of your credential? Commented Feb 10, 2019 at 3:50

1 Answer 1

2

I just stumbled over the answer myself:

import org.jenkinsci.plugins.github.config.GitHubPluginConfig import org.jenkinsci.plugins.github.config.GitHubServerConfig def github = jenkins.model.Jenkins.instance.getExtensionList(GitHubPluginConfig.class)[0] github.setConfigs([ new GitHubServerConfig("github-access-token"), ]) github.save() 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.