Thanks, I didn’t notice the “Use Groovy sandbox”, and it works after I 
unchecked it.

println job.getRawBuild().getEnvironment()[“uuid"]
println 
Jenkins.instance.getItemByFullName(“test").getAllJobs()[0].getLastSuccessfulBuild().getEnvironment()["uuid"]

Both work for me.


Regards,
Stanley





> On Jun 29, 2017, at 1:24 AM, Richard Ginga <[email protected]> wrote:
> 
> #1. try unclicking "Use Groovy sandbox" at the bottom of the script window.
> 
> #1 and #2 could be you don't have permissions. I am an admin of my jenkins 
> master
> 
> 
> On Wed, Jun 28, 2017 at 1:13 PM, Stanley Shen <[email protected] 
> <mailto:[email protected]>> wrote:
> Thanks for replying.
> 
> I tried solution #1 you provided, but it report error like 
> "org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: 
> Scripts not permitted to use method”
> 
> For #2, it also report error like 
> “org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: 
> Scripts not permitted to use staticMethod jenkins.model.Jenkins getInstance”
> 
> 
> Any idea on it.
> 
> 
> Regards,
> Stanley
> 
> 
> 
> 
> 
> 
>> On Jun 28, 2017, at 8:04 PM, Richard Ginga <[email protected] 
>> <mailto:[email protected]>> wrote:
>> 
>> The things you "can" get from the returned object (c) from a pipeline 
>> statement like: c = build job: "test job1" are here: 
>> 
>> https://github.com/jenkinsci/workflow-support-plugin/blob/master/src/main/java/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapper.java
>>  
>> <https://github.com/jenkinsci/workflow-support-plugin/blob/master/src/main/java/org/jenkinsci/plugins/workflow/support/steps/build/RunWrapper.java>
>> 
>> you might be able to do something with the non-whitelisted getRawBuild 
>> method.
>> 
>> Otherwise, to get that job's env variables you must do something "like" 
>> this: (untested)
>> 
>> Jenkins.instance.getItemByFullName("test 
>> job1").getAllJobs()[0].getLastSuccessfulBuild().getEnv("uuid")
>> 
>> On Tue, Jun 27, 2017 at 9:21 PM, <[email protected] 
>> <mailto:[email protected]>> wrote:
>> Hello, all
>> 
>> I am trying to trigger a freestyle job in pipeline and need to get a inject 
>> environment from that job.
>> Before with flow job, we can use thing like 
>> 
>> c = build("test job1")
>> uuid = c.build.properties["environment"]["uuid"]
>> 
>> But I didn't find a way to do this similar in pipeline script.
>> 
>> Is there any hint on it?
>> 
>> 
>> -- 
>> 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] 
>> <mailto:[email protected]>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-users/fa73e7a7-ea85-4eee-8f8e-037689bff630%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jenkinsci-users/fa73e7a7-ea85-4eee-8f8e-037689bff630%40googlegroups.com?utm_medium=email&utm_source=footer>.
>> For more options, visit https://groups.google.com/d/optout 
>> <https://groups.google.com/d/optout>.
>> 
>> 
>> 
>> -- 
>> Dick Ginga
>> Build Engineer
>> [email protected] <mailto:[email protected]>
>> 
>> 
>> -- 
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "Jenkins Users" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/jenkinsci-users/ouDKTknbt7k/unsubscribe 
>> <https://groups.google.com/d/topic/jenkinsci-users/ouDKTknbt7k/unsubscribe>.
>> To unsubscribe from this group and all its topics, send an email to 
>> [email protected] 
>> <mailto:[email protected]>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-users/CAL3PpaVGzRL2j_rNYAhAsSPxw2F8gpotuLhpZiA3DOjkYXgDUw%40mail.gmail.com
>>  
>> <https://groups.google.com/d/msgid/jenkinsci-users/CAL3PpaVGzRL2j_rNYAhAsSPxw2F8gpotuLhpZiA3DOjkYXgDUw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>> For more options, visit https://groups.google.com/d/optout 
>> <https://groups.google.com/d/optout>.
> 
> 
> -- 
> 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] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jenkinsci-users/50176E3F-E26F-413E-A4E3-E69195EE0021%40servicemax.com
>  
> <https://groups.google.com/d/msgid/jenkinsci-users/50176E3F-E26F-413E-A4E3-E69195EE0021%40servicemax.com?utm_medium=email&utm_source=footer>.
> 
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.
> 
> 
> 
> -- 
> Dick Ginga
> Build Engineer
> [email protected] <mailto:[email protected]>
> 
> 
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "Jenkins Users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/jenkinsci-users/ouDKTknbt7k/unsubscribe 
> <https://groups.google.com/d/topic/jenkinsci-users/ouDKTknbt7k/unsubscribe>.
> To unsubscribe from this group and all its topics, send an email to 
> [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jenkinsci-users/CAL3PpaV%2B6stTpw5P6HPftn9tgGrvKki%2Be%3DPYjxxDK%2BTGJM%2Bv4Q%40mail.gmail.com
>  
> <https://groups.google.com/d/msgid/jenkinsci-users/CAL3PpaV%2B6stTpw5P6HPftn9tgGrvKki%2Be%3DPYjxxDK%2BTGJM%2Bv4Q%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
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/E4D8B530-48C4-41C0-9900-192E7DB01A16%40servicemax.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to