Re: How to get a plugin's configuration from the system Groovy?

212 views
Skip to first unread message

Daniel Spilker

unread,
Aug 19, 2014, 3:51:54 AM8/19/14
to jenkin...@googlegroups.com, job-dsl...@googlegroups.com
Hi,

you can use the following lines in your Job DSL script to get a mapping of settings names to IDs.

import jenkins.model.Jenkins

Jenkins jenkins = Jenkins.getInstance()
def mavenSettingsConfigProvider = jenkins.getExtensionList("org.jenkinsci.plugins.configfiles.maven.MavenSettingsConfig\$MavenSettingsConfigProvider")[0]
Map<String, String> mavenSettings = mavenSettingsConfigProvider.allConfigs.collectEntries { [it.name, it.id] }

By coincidence, I opened a pull request for the Job DSL Plugin which add DSL support for Maven settings: https://github.com/jenkinsci/job-dsl-plugin/pull/269

I'm planning to release a new version of the Job DSL Plugin containing these changes in the next two weeks. In the meantime you can also use the latest SNAPSHOT build which already contains the changes: http://repo.jenkins-ci.org/simple/snapshots/org/jenkins-ci/plugins/job-dsl/1.25-SNAPSHOT/

Please use the Job DSL mailing list for any Job DSL questions: https://groups.google.com/forum/?fromgroups#!forum/job-dsl-plugin

Daniel

On Monday, August 18, 2014 10:32:07 AM UTC+2, Constantin Caraivan wrote:

Hello,

I'm using the https://wiki.jenkins-ci.org/display/JENKINS/Config+File+Provider+Plugin to manage Maven settings files.
I want to generate Jenkins jobs using the DSL plugin: https://wiki.jenkins-ci.org/display/JENKINS/Job+DSL+Plugin

Unfortunately, the config file provider uses generated IDs in the configuration:
<settings class="org.jenkinsci.plugins.configfiles.maven.job.MvnSettingsProvider" plugin="config-file-provider@2.7.5">
<settingsConfigId>org.jenkinsci.plugins.configfiles.maven.MavenSettingsConfig1408033012483</settingsConfigId>
</settings>

Short of hardcoding the ID (1408033012483) in the DSL, is there a way to get a plugin's configuration from the system Groovy? Ideally I'd like a way to interrogate Jenkins or the plugin about the configuration it stores based on the names I've given them.

Thank you,
_____________
Costin Caraivan

Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages