Hi,

you mean upstreamResult/build_result?

What does the println for upstreamResult say?
Which Jenkins version are you on?

BR :)

On 9 December 2022 22:56:29 CET, "[email protected]" <[email protected]> 
wrote:
>Hi!  Not sure what's going on but I have a groovy script that has been 
>setting the variable build_status for ages but it stopped working.  
> Doesn't set the variable any longer.  Any ideas?  Here's the script:
>
>import hudson.model.*
>
>import jenkins.model.*
>
>  
>
>def resolver = Thread.currentThread().executable.buildVariableResolver
>
>def parent_job = resolver.resolve("upstream_job")
>
>def parent_build_number = resolver.resolve("upstream_bn")
>
> 
>
>def upstreamResult = 
>Hudson.instance.getJob("${parent_job}").getLastBuild().result
>
> 
>
>if(upstreamResult.equals(hudson.model.Result.FAILURE)) {
>
>  upstreamResult = "fail"
>
>} else {
>
>  upstreamResult = "${upstreamResult}".toLowerCase()  
>
>}
>
>println "upstream result: ${upstreamResult}"
>
> 
>
>def newParams = null
>
>def pl = new ArrayList<StringParameterValue>()
>
> 
>
>pl.add(new StringParameterValue('build_result', upstreamResult))
>
> 
>
>def oldParams = build.getAction(ParametersAction.class)
>
>if(oldParams != null) {
>
>  newParams = oldParams.createUpdated(pl)
>
>  build.actions.remove(oldParams)
>
>} else {
>
>  newParams = new ParametersAction(pl)
>
>}
>
> 
>
>build.addAction(newParams)
>
>
>Thanks,
>Eric
>
>-- 
>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 [email protected].
>To view this discussion on the web visit 
>https://groups.google.com/d/msgid/jenkinsci-users/696cf40d-52da-40db-b7da-0bd974551104n%40googlegroups.com.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CCA79DCC-D33F-47B0-9430-DC7483BF969B%40chsc.de.

Reply via email to