Set Slave ToolInstallation path with groovy cli script

96 views
Skip to first unread message

Matt Gollob

unread,
Nov 7, 2012, 3:42:54 PM11/7/12
to jenkin...@googlegroups.com
Hello everyone,

I'm looking for help with writing a groovy script for use with jenkins-cli that can set the ToolInstallation path for a particular slave and tool.  In https://wiki.jenkins-ci.org/display/JENKINS/Display+Tools+Location+on+All+Nodes I see how I can enumerate all the tools and their installations.  However, not being a Java developer, I'm having trouble figuring out what the inverse of ToolInstallation.translateFor() might be.

First off, is it possible to set the tool path for a slave from a cli/groovy script?  If so, can someone point me in the right direction for how I might set (and save) a new path?

Thanks a lot,
Matt

Jesse Glick

unread,
Nov 7, 2012, 7:22:20 PM11/7/12
to jenkin...@googlegroups.com
On 11/07/2012 03:42 PM, Matt Gollob wrote:
> I'm having trouble figuring out what the inverse of ToolInstallation.translateFor() might be

Hint: hudson.tools.ToolLocationNodeProperty

Matt Gollob

unread,
Nov 12, 2012, 10:43:20 AM11/12/12
to jenkin...@googlegroups.com
I'm sorry, but I need a little more explicit direction.  I found the source for ToolLocationNodeProperty, but the class has no setters, so am I supposed to create a new instance?  I don't want to add a location, I want to change the one that's already there, so a new instance doesn't seem like the right thing to do.

Even if I have a new instance, I have to set that on something, but the Slave class doesn't seem to have a setter for the properties collection either, so I'm at loss as to how to get my new instance into the Slave's property collection.  Also, I don't quite grok the relationship between a property and a descriptor.  They seem to both point to collections of each other, and neither has a setter for home so no help there in trying to figure out which one I'm supposed to be dealing with.

I also found NodeProperty.reconfigure(), but have no idea what a StaplerRequest is or where I'd get one from, nor do have the JSONObject that I assume represents the configuration.  Is this the route I should be heading down?  I think this might actually be intended for use by the web UI and not CLI/Groovy.  How can I get the JSON for the current configuration for the slave so I can figure out which part to modify?

What would be most helpful is a block of code (even pseudo-code would help) outlining what I need to do to set the path to the tool.

Sorry to be such a newbie about this, but there's some connection between all these types that I'm just not seeing.

Thanks for the help,
Matt

Jesse Glick

unread,
Nov 12, 2012, 11:25:39 AM11/12/12
to jenkin...@googlegroups.com
On 11/12/2012 10:43 AM, Matt Gollob wrote:
> I need a little more explicit direction.

Sorry, no time to help more; maybe someone else can chime in.

Nico Mommaerts

unread,
Sep 17, 2014, 9:12:34 AM9/17/14
to jenkin...@googlegroups.com
For people who still might stumble upon this:
Reply all
Reply to author
Forward
0 new messages