Fortunately, it's already there.
Unfortunately, I can't trust to this 'Run', that's why we used 
`Thread.currentThread().executable`.

Why it's impossible to trust:
* Our master is pretty highloaded (several jobs can be finilazed in same 
moment, from 90k-120k executions per day)
* To avoid script compilation every time plugin shares Script object 
between different threads/builds.
* groovyScript.setBinding(new Binding(params)) is not thread-safe

If I understood Daniel correctly, `currentBuild` should be available? But, 
maybe, only from different class loader?
Can I patch Jenkins to provide similar to Thread.currentThread().executable 
behaviour for pipeline jobs as well?

p.s. I know that I can avoid shared state in plugin by compiling script 
every time, but I don't do that as well, because we are trying to reduce 
memory usage as much as possible.

On Tuesday, 23 August 2016 22:28:34 UTC+2, Jesse Glick wrote:
>
> On Tue, Aug 23, 2016 at 7:20 AM, Jimilian <[email protected] 
> <javascript:>> wrote: 
> > I forgot to add that we are using Groovy Event Listener Plugin to 
> publish 
> > data. So, this script is executed in 'onFinalized' method. 
>
> So patch that plugin to actually take the `Run` it received in 
> `onFinalized` and make it available to the script. 
>

-- 
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/61bb88d5-411f-4cf9-89f6-c4132594e27e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to