I have hundreds of Jobs that I would like to programmatically add an 
initial build step to using the Build Flow Plugin

When I try something like this ...

        String jobName = "MY_JOB";
List<TopLevelItem> topLevelItems = 
Jenkins.getInstance().getAllItems(TopLevelItem.class);
Job job;
Iterator<TopLevelItem> topLevelItemsIterator = topLevelItems.iterator();
while (topLevelItemsIterator.hasNext()) {
TopLevelItem topLevelItem = topLevelItemsIterator.next();
Collection<? extends Job> jobs = topLevelItem.getAllJobs();
        job = (jobs.toArray())[0];
if (job.getName().equals(jobName)) {
break;
} else {
job = null;
    }
}
FreeStyleProject project = (FreeStyleProject) job;
List<Builder> builders = project.getBuilders();
Shell propertyVersionsCommand = new Shell("echo 'Hello World'");
builders.add(0, propertyVersionsCommand);


I get ...

ERROR: Failed to run DSL Scriptjava.lang.UnsupportedOperationException 
<http://stacktrace.jenkins-ci.org/search?query=java.lang.UnsupportedOperationException>
  at java.util.Collections$UnmodifiableList.add(Collections.java:1216) 
<http://stacktrace.jenkins-ci.org/search/?query=java.util.Collections$UnmodifiableList.add&entity=method>
        at java_util_List$add$0.call(Unknown Source)
        at 
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
        at 
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
        at 
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
        at Script1.setPropertyVersions(Script1.groovy:227)
        at Script1$setPropertyVersions.callCurrent(Unknown Source)
        at 
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
        at 
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
        at 
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
        at Script1.run(Script1.groovy:193)
        at Script1$run.call(Unknown Source)
        at 
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
        at Script1$run.call(Unknown Source)
        at 
com.cloudbees.plugins.flow.FlowDSL.executeFlowScript(FlowDSL.groovy:82)



Under "Project-based Matrix Authorization Strategy" I've confirmed that I have 
EVERY perm possible checked there.


What am I missing?


-Steve

Orlando, FL

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to