Thanks. That's what I was suspecting that I'll have to do but didn't find the code to do it. I'll also have to be able to somehow copy over everything else from the existing object except for this change. Would you know where can I find an example, or at least a class name to look for?
Cheers. On Thursday, 31 July 2014 21:58:42 UTC+10, Robert Sandell wrote: > > Construct a new builder object and replace the old one, that is basically > what the save button does. > > /B > > > 2014-07-31 9:05 GMT+02:00 Amos S <[email protected] <javascript:>>: > >> Hello, >> >> I'm trying to change the names of projects which will be triggered by a >> build via the Groovy console. >> >> I got as far as being able to extract the field from the data structures >> but didn't find a way to set it with a new value. >> >> Here is the code I got so far: >> >> import hudson.model.* >> import hudson.model.FreeStyleProject >> import jenkins.model.Jenkins >> import hudson.plugins.parameterizedtrigger.TriggerBuilder >> >> def viewName = "v2.9" >> >> Jenkins jenkins = Jenkins.getInstance() >> >> jenkins.getView(viewName).getItems().each { item -> >> def jobName = item.getName() >> FreeStyleProject job = jenkins.getItem(jobName) >> >> job.builders.each { builder -> >> if (builder.metaClass.respondsTo(builder, "getConfigs")) { >> builder.getConfigs().each { config -> >> println("projects to build: \"" + config.getProjects() + >> "\"") >> } >> } >> } >> } >> >> so "getProjects()" returns to be the content of the field I want to >> change, here is the field I want to change: >> >> >> <https://lh6.googleusercontent.com/-RPzN50sJ3zo/U9nqhFHwV9I/AAAAAAAAL7I/z8_PfaWTw-o/s1600/Screen+Shot+2014-07-31+at+5.04.08+pm.png> >> >> How can I achieve this? >> >> Thanks. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Jenkins Developers" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Jenkins Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
