-
Improvement
-
Resolution: Not A Defect
-
Minor
-
None
-
Jenkins 2.165
Latest version of this plugin: 3.5
I am trying to create a groovy init script to save multiple maven config files and custom config files within a single script, for some reasons it is honoring either one of them. Looks like I am missing something. Appreciate if someone can help me look into this file.
import org.jenkinsci.plugins.configfiles.maven.MavenSettingsConfig import org.jenkinsci.plugins.configfiles.custom.CustomConfig import org.jenkinsci.plugins.configfiles.maven.security.ServerCredentialMapping // Maven config files. def mavenProvider = instance.getExtensionList('org.jenkinsci.plugins.configfiles.maven.MavenSettingsConfig$MavenSettingsConfigProvider')[0] config?.maven?.each { key, config -> println("Adding maven settings with key: ${key}") def serverCreds = new ArrayList() config.servers.each { server -> def serverCredentialMapping = new ServerCredentialMapping(server.serverId, server.credentialsId) serverCreds.add(serverCredentialMapping) } def mavenConfig = new MavenSettingsConfig(config.id, config.name, config.comment, config.content, Boolean.parseBoolean(config.replaceAll), serverCreds) mavenProvider.save(mavenConfig) } // Custom config files. def customProvider = instance.getExtensionList('org.jenkinsci.plugins.configfiles.custom.CustomConfig$CustomConfigProvider')[0] config?.custom?.each { key, config -> println("Adding custom file with key: ${key}") def customConfig = new CustomConfig(config.id, config.name, config.comment, config.content) customProvider.save(customConfig) }
I got to remove one of these two like either custom config files section or the maven config files section to get this work, I have also tried moving one of the sections to different files but no luck.