That was the problem. Thank you.
I found that there was duplicate EnvInjectJobProperty within config.xml

I will update my script to remove the existing before adding the new.

mandag 18. april 2016 12.31.57 UTC+2 skrev Daniel Beck følgende:
>
> You're never removing any potentially existing job properties, just 
> adding. So it's likely you just get the old one returned from your API 
> call, as the job properties list does not really support having two of the 
> same type (but doesn't prevent it either). Confirm by looking at the 
> config.xml. 
>
> > On 18.04.2016, at 09:27, Sverre Moe <[email protected] <javascript:>> 
> wrote: 
> > 
> > I am not sure what I am doing wrong with my groovy script. 
> > I have written a groovy update script to bulk update all my projects. 
> > Sometimes it does not take affect when I call project.save() 
> > I can afterwards open that project configuration page and everything 
> looks right. The updated content is there. 
> > However when I write a groovy read script to print out that information 
> I updated, not all projects show the updated information. 
> > If I then open those projects configuration page, do nothing and just 
> press save then that information is available when I run the read script 
> again. 
> > 
> > Making a change in Script console using Groovy and then envoke 
> project.save(), why is it that when I try to read the value again it does 
> not show the changed value, but the old one. 
> > 
> > Do I need to perform some other action than just project.save() 
> > 
> > For instance given this groovy script to add some environment variables. 
> > #!/usr/bin/env groovy 
> > 
> > import java.lang.StringBuilder 
> > import hudson.matrix.MatrixProject 
> > import org.jenkinsci.plugins.envinject.EnvInjectJobProperty 
> > import org.jenkinsci.plugins.envinject.EnvInjectJobPropertyInfo 
> > 
> > def jenkinsInstance = jenkins.model.Jenkins.getInstance() 
> > def developmentView = jenkinsInstance.getView("myView") 
> > developmentView.getItems().each { project -> 
> > 
> >     StringBuilder builder = new StringBuilder() 
> >     builder.append("NO_CPPCHECK=true") 
> >     builder.append("\n") 
> >     builder.append("NO_INSTALL=true") 
> >     final def propertiesContent = builder.toString() 
> > 
> >     def info = new EnvInjectJobPropertyInfo(null, propertiesContent, 
> null, null, null, false) 
> >     def property = new EnvInjectJobProperty() 
> >     property.setOn(true) 
> >     property.setKeepJenkinsSystemVariables(true) 
> >     property.setKeepBuildVariables(true) 
> >     property.setInfo(info) 
> > 
> >     project.addProperty(property) 
> >     project.save() 
> > } 
> > 
> > Trying to read the same environment variables 
> > #!/usr/bin/env groovy 
> > 
> > import org.jenkinsci.plugins.envinject.EnvInjectJobProperty 
> > import org.jenkinsci.plugins.envinject.EnvInjectJobPropertyInfo 
> > 
> > def jenkinsInstance = jenkins.model.Jenkins.getInstance() 
> > def developmentView = jenkinsInstance.getView("myView") 
> > developmentView.getItems().each { project -> 
> >   def EnvInjectJobProperty property = 
> project.getProperty(EnvInjectJobProperty.class) 
> >   if (property != null) { 
> >     def info = property.getInfo() 
> >     println info.getPropertiesContent() 
> >   } 
> > } 
> > 
> > Not all projects now shows the environment variables. 
> > 
> > -- 
> > 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:>. 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jenkinsci-dev/37b712cb-5407-4359-bacd-37a700ef8aed%40googlegroups.com.
>  
>
> > 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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/38857f6a-357e-4f54-bb88-58e3d50144c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to