jenkins-gitlab-merge-request-builder-plugin icon indicating copy to clipboard operation
jenkins-gitlab-merge-request-builder-plugin copied to clipboard

Plugin configuration by groovy

Open joachimmathes opened this issue 8 years ago • 2 comments

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

joachimmathes avatar Aug 24 '16 14:08 joachimmathes

Is there any progress with this? Would be really helpful.

Chrislevi avatar Jul 02 '17 13:07 Chrislevi

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()
}

k0chan avatar Oct 16 '17 14:10 k0chan