Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin configuration by groovy #194

Open
joachimmathes opened this issue Aug 24, 2016 · 2 comments
Open

Plugin configuration by groovy #194

joachimmathes opened this issue Aug 24, 2016 · 2 comments

Comments

@joachimmathes
Copy link

joachimmathes commented Aug 24, 2016

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

@Chrislevi
Copy link

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

@k0chan
Copy link

k0chan commented Oct 16, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants