Last active
August 29, 2015 14:00
-
-
Save colinPL/11159398 to your computer and use it in GitHub Desktop.
Revisions
-
colinPL revised this gist
Apr 22, 2014 . 1 changed file with 10 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,18 +1,18 @@ // add-jenkins-param.groovy // Adds a parameter to all jobs on a Jenkins instance. // The parameter is then exposed to the job's environment as `$PARAM_KEY`. import hudson.model.* key = 'GEM_SOURCE' value = 'http://rubygems.delivery.puppetlabs.net:5000' desc = 'The rubygems URL' for(job in Hudson.instance.items) { // TODO: this doesn't work. Don't use it! println("[ " + job.name + " ] setting " + key + "=" + value) newParam = new StringParameterDefinition(key, value, desc) paramDef = job.getProperty(ParametersDefinitionProperty.class) if (paramDef == null) { @@ -22,10 +22,11 @@ for(job in Hudson.instance.items) { job.addProperty(newParamDef) } else { // Parameters exist! We should check if this one exists already! found = paramDef.parameterDefinitions.find{ it.name == key } if (found == null) { paramDef.parameterDefinitions.add(newParam) } } //job.save() println() } -
colinPL revised this gist
Apr 21, 2014 . 1 changed file with 17 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,25 +1,31 @@ // add-jenkins-param.groovy // Adds a parameter to all jobs on a Jenkins instance. // The parameter is then exposed to the job's environment as `$PARAM_KEY`. import hudson.model.* key = 'GEM_SOURCE' value = 'http://rubygems.delivery.puppetlabs.net:5000' for(job in Hudson.instance.items) { // TODO: this doesn't work. Don't use it! println("[ " + job.name + " ] setting " + key + "=" + value) newParam = new StringParameterDefinition(key, value) paramDef = job.getProperty(ParametersDefinitionProperty.class) if (paramDef == null) { newArrList = new ArrayList<ParameterDefinition>(1) newArrList.add(newParam) newParamDef = new ParametersDefinitionProperty(newArrList) job.addProperty(newParamDef) } else { // Parameters exist! We should check if this one exists already! if (!paramDef.parameterDefinitions.contains(newParam)) { paramDef.parameterDefinitions.add(newParam) } } job.save() println() } -
Roger Ignazio revised this gist
Apr 21, 2014 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,11 +7,11 @@ import hudson.model.* key = 'GEM_SOURCE' value = 'http://rubygems.delivery.puppetlabs.net' for(job in Hudson.instance.items) { // TODO: this doesn't work. Don't use it! println("[ " + job.name + " ] setting " + key + "=" + value) prop = job.getProperty(ParametersDefinitionProperty.class) pd = new StringParameterDefinition(key, value) java.util.List<ParameterDefinition> params = new java.util.ArrayList<ParameterDefinition>() @@ -22,4 +22,4 @@ for(item in Hudson.instance.items) { job.addProperty(pdp) job.save() println() } -
Roger Ignazio created this gist
Apr 21, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ // add-jenkins-param.groovy // Adds a parameter to all jobs on a Jenkins instance. // The parameter is then exposed to the job's environment as `$PARAM_KEY`. import hudson.model.* key = 'GEM_SOURCE' value = 'http://rubygems.delivery.puppetlabs.net' for(item in Hudson.instance.items) { // TODO: this doesn't work. Don't use it! println("[ " + job.name + " ] setting " + key + "=" + value) prop = item.getProperty(ParametersDefinitionProperty.class) pd = new StringParameterDefinition(key, value) java.util.List<ParameterDefinition> params = new java.util.ArrayList<ParameterDefinition>() params.addAll(prop?.parameterDefinitions) params.add(pv) pdp = new ParametersDefinitionProperty(pd) job.addProperty(pdp) job.save() println() }