Getting Current Build in Groovy

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting Current Build in Groovy

Jay Flowers
This use to work for me:

def build = Thread.currentThread().executable

Now I get this error:

Caught: groovy.lang.MissingPropertyException: No such property: executable for class: java.lang.Thread
	at hudson2123325863987208585.run(hudson2123325863987208585.groovy:5)

Why oh why is the happening? :-)  Anyone know...


--
Jay Flowers
----------------------------------------------------------------------
http://jayflowers.com
---------------------------------------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: Getting Current Build in Groovy

Vojtech Juranek
Do you run it withing a Jenkins build in master JVM? For me still works fine

> This use to work for me:
>
> def build = Thread.currentThread().executable
>
> Now I get this error:
>
> Caught: groovy.lang.MissingPropertyException: No such property:
> executable for class: java.lang.Thread
> at hudson2123325863987208585.run(hudson2123325863987208585.groovy:5)
>
>
> Why oh why is the happening? :-)  Anyone know...
Reply | Threaded
Open this post in threaded view
|

Re: Getting Current Build in Groovy

Jay Flowers
In reply to this post by Jay Flowers
I figured it out...  I was not running the Groovy script as the build step type "Execute system Groovy script"


On Thu, Mar 15, 2012 at 9:00 AM, Jay Flowers <[hidden email]> wrote:
This use to work for me:

def build = Thread.currentThread().executable

Now I get this error:

Caught: groovy.lang.MissingPropertyException: No such property: executable for class: java.lang.Thread
	at hudson2123325863987208585.run(hudson2123325863987208585.groovy:5)

Why oh why is the happening? :-)  Anyone know...


--
Jay Flowers
----------------------------------------------------------------------
http://jayflowers.com
---------------------------------------------------------------------



--
Jay Flowers
----------------------------------------------------------------------
http://jayflowers.com
---------------------------------------------------------------------
Reply | Threaded
Open this post in threaded view
|

Re: Getting Current Build in Groovy

Neel Desai
But are you runnint this job on master JVM? What about running it from slave node? How can I get the value? I am trying to execute it from slave node and it is giving me error. It is strict requirement for me to run it from slave machine only.

On Thursday, March 15, 2012 at 8:47:03 AM UTC-5, Jay Flowers wrote:
I figured it out...  I was not running the Groovy script as the build step type "Execute system Groovy script"


On Thu, Mar 15, 2012 at 9:00 AM, Jay Flowers <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="9xLHOofwCmQJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jay.f...@...> wrote:
This use to work for me:

def build = Thread.currentThread().executable

Now I get this error:

Caught: groovy.lang.MissingPropertyException: No such property: executable for class: java.lang.Thread
	at hudson2123325863987208585.run(hudson2123325863987208585.groovy:5)

Why oh why is the happening? :-)  Anyone know...


--
Jay Flowers
----------------------------------------------------------------------
<a href="http://jayflowers.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjayflowers.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEi1qlLZ0J9UJjJGB0wx8TG-AXNow&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjayflowers.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEi1qlLZ0J9UJjJGB0wx8TG-AXNow&#39;;return true;">http://jayflowers.com
---------------------------------------------------------------------



--
Jay Flowers
----------------------------------------------------------------------
<a href="http://jayflowers.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjayflowers.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEi1qlLZ0J9UJjJGB0wx8TG-AXNow&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fjayflowers.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEi1qlLZ0J9UJjJGB0wx8TG-AXNow&#39;;return true;">http://jayflowers.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/0e6ecdfa-94c1-4c4a-8140-4f2bbbcefde4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Getting Current Build in Groovy

Lee Meador-3
I'm a little fuzzy on all the ins and outs of it but I believe that line of groovy code above always runs on the master anyway.

The Java class Thread has no property 'executable' so its telling you the truth.

On Thu, Nov 2, 2017 at 1:02 PM, Neel Desai <[hidden email]> wrote:
But are you runnint this job on master JVM? What about running it from slave node? How can I get the value? I am trying to execute it from slave node and it is giving me error. It is strict requirement for me to run it from slave machine only.

On Thursday, March 15, 2012 at 8:47:03 AM UTC-5, Jay Flowers wrote:
I figured it out...  I was not running the Groovy script as the build step type "Execute system Groovy script"


On Thu, Mar 15, 2012 at 9:00 AM, Jay Flowers <[hidden email]> wrote:
This use to work for me:

def build = Thread.currentThread().executable

Now I get this error:

Caught: groovy.lang.MissingPropertyException: No such property: executable for class: java.lang.Thread
	at hudson2123325863987208585.run(hudson2123325863987208585.groovy:5)

Why oh why is the happening? :-)  Anyone know...


--
Jay Flowers
----------------------------------------------------------------------
http://jayflowers.com
---------------------------------------------------------------------



--
Jay Flowers
----------------------------------------------------------------------
http://jayflowers.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/0e6ecdfa-94c1-4c4a-8140-4f2bbbcefde4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
-- Lee Meador
Sent from gmail. My real email address is lee AT leemeador.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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAA4vtDTRPZ%2BzHs%3D%3DTF-sZ6nQ-9oA_LeEUHjnpKAxrgeFa8J4uA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [EXTERNAL] - Re: Getting Current Build in Groovy

Dirk Heinrichs-3
Am 03.11.2017 um 15:37 schrieb Lee Meador:

I'm a little fuzzy on all the ins and outs of it but I believe that line of groovy code above always runs on the master anyway.

Where Groovy code runs depends on the type of build step. A "System Groovy Script" step always runs on the master, regardless of where the actual job runs. A normal "Groovy Script" step always runs on the node which executes the job. There's no way that a single line of one script would run on another node.

Bye...

    Dirk
--
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenTextTM Discovery | Recommind
Email: [hidden email]
Website: www.recommind.de

Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach

Vertretungsberechtigte Geschäftsführer John Marshall Doolittle, Gordon Davies, Roger Illing, Registergericht Amtsgericht Bonn, Registernummer HRB 10646

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/e2657063-ecb0-c34b-f679-4c3ce2bfdd18%40opentext.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [EXTERNAL] - Re: Getting Current Build in Groovy

Neel Desai
That's my question. 

I know that only "Execute System Groovy script" can run on master and get this property but I want to get it from worker node. From worker node I want to get current jenkins instance.

On Monday, November 6, 2017 at 4:38:10 AM UTC-6, Dirk Heinrichs wrote:
Am 03.11.2017 um 15:37 schrieb Lee Meador:

I'm a little fuzzy on all the ins and outs of it but I believe that line of groovy code above always runs on the master anyway.

Where Groovy code runs depends on the type of build step. A "System Groovy Script" step always runs on the master, regardless of where the actual job runs. A normal "Groovy Script" step always runs on the node which executes the job. There's no way that a single line of one script would run on another node.

Bye...

    Dirk
--
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenTextTM Discovery | Recommind
Email: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="jKL9kP_YBAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dirk.he...@...
Website: <a href="http://www.recommind.de" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.recommind.de\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGAI0xqX2_aTOJli63C7-WL52SKuQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.recommind.de\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGAI0xqX2_aTOJli63C7-WL52SKuQ&#39;;return true;">www.recommind.de

Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach

Vertretungsberechtigte Geschäftsführer John Marshall Doolittle, Gordon Davies, Roger Illing, Registergericht Amtsgericht Bonn, Registernummer HRB 10646

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/b0512af2-eed4-4467-8e94-803dc7bcd1a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Getting Current Build in Groovy

Dirk Heinrichs-3
Am 06.11.2017 um 17:25 schrieb Neel Desai:

I know that only "Execute System Groovy script" can run on master and get this property but I want to get it from worker node. From worker node I want to get current jenkins instance.

I don't think you can. Only System Groovy scripts run in the exact same JVM as the master and thus have access to Jenkins internals. Normal Groovy scripts run inside their own JVM and thus don't even know they're running on Jenkins (except for some additional environment variables that Jenkins sets).

HTH...

    Dirk
--
Dirk Heinrichs
Senior Systems Engineer, Delivery Pipeline
OpenTextTM Discovery | Recommind
Email: [hidden email]
Website: www.recommind.de

Recommind GmbH, Von-Liebig-Straße 1, 53359 Rheinbach

Vertretungsberechtigte Geschäftsführer John Marshall Doolittle, Gordon Davies, Roger Illing, Registergericht Amtsgericht Bonn, Registernummer HRB 10646

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht gestattet.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/4b163eb4-4c17-67a9-615d-26695a648770%40opentext.com.
For more options, visit https://groups.google.com/d/optout.