jenkins-gitlab-merge-request-builder-plugin
jenkins-gitlab-merge-request-builder-plugin copied to clipboard
Plugin configuration by groovy
Feature Request: It would be great if the global plugin parameters could be set by something like:
import jenkins.model.*
def inst = Jenkins.getInstance()
def desc = inst.getDescriptor("org.jenkinsci.plugins.gitlab.GitlabBuildTrigger")
desc.setBotUsername("foo")
desc.getGitlabHostUrl("http://gitlab.foobar.de")
desc.save()
Maybe it's already possible and I just don't know how to do it correctly.
Thanks in advance! Jo
Is there any progress with this? Would be really helpful.
It works for me
println "Configuring gitlab"
def jenkins = Jenkins.getInstance()
def gitLabConfig = jenkins.getDescriptor("com.dabsquared.gitlabjenkins.connection.GitLabConnectionConfig")
GitLabConnection connection = new GitLabConnection('name', 'url','apiToken', false ,10, 10)
boolean gitlabMissing = gitLabConfig.getConnections().findAll() {
it.getName() == connection.name
}.empty
if(gitlabMissing) {
println "Adding new gitlab server"
gitLabConfig.addConnection(connection)
gitLabConfig.save()
}