通过 Groovy 添加 GitHub 服务器到 Jenkins
Adding GitHub Server to Jenkins via Groovy
我正在尝试通过 Groovy 初始化脚本配置我们的 Jenkins 服务器。我被困在如何以某种方式配置 Github Plugin. I want Jenkins to manage my hooks. So I need to add a GitHubServerConfig to the GitHubPluginConfig 上。我已经设法设置了凭据。所以到目前为止我有这段代码:
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()
但这没有任何影响。有什么建议吗?
我自己偶然发现了答案:
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()
我正在尝试通过 Groovy 初始化脚本配置我们的 Jenkins 服务器。我被困在如何以某种方式配置 Github Plugin. I want Jenkins to manage my hooks. So I need to add a GitHubServerConfig to the GitHubPluginConfig 上。我已经设法设置了凭据。所以到目前为止我有这段代码:
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()
但这没有任何影响。有什么建议吗?
我自己偶然发现了答案:
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()