Getting Current Build in Groovy

1,786 views
Skip to first unread message

Jay Flowers

unread,
Mar 15, 2012, 9:00:00 AM3/15/12
to jenkins...@googlegroups.com
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
---------------------------------------------------------------------

Vojtech Juranek

unread,
Mar 15, 2012, 9:45:28 AM3/15/12
to jenkins...@googlegroups.com
Do you run it withing a Jenkins build in master JVM? For me still works fine

Jay Flowers

unread,
Mar 15, 2012, 9:47:03 AM3/15/12
to jenkins...@googlegroups.com
I figured it out...  I was not running the Groovy script as the build step type "Execute system Groovy script"

Neel Desai

unread,
Nov 2, 2017, 2:02:19 PM11/2/17
to Jenkins Users
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.

Lee Meador

unread,
Nov 3, 2017, 10:37:59 AM11/3/17
to jenkins...@googlegroups.com
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.

--
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 jenkinsci-users+unsubscribe@googlegroups.com.
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

Dirk Heinrichs

unread,
Nov 6, 2017, 5:38:10 AM11/6/17
to jenkins...@googlegroups.com
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: dirk.he...@recommind.com
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.

Neel Desai

unread,
Nov 6, 2017, 11:25:14 AM11/6/17
to Jenkins Users
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.

Dirk Heinrichs

unread,
Nov 7, 2017, 1:54:18 AM11/7/17
to jenkins...@googlegroups.com
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...
Reply all
Reply to author
Forward
0 new messages