Groovy script vs. system script : file info needed to affect build

70 views
Skip to first unread message

Brantone

unread,
Aug 11, 2015, 9:10:59 PM8/11/15
to Jenkins Users
I'm well aware of the differences (and headaches) between Groovy script and system Groovy script .. my question involves the following scenario:
After an SCM checkout is done on remote slave node, need to grep for a string in a specific file, whose value will be used for all downstream jobs, preferably added as a parameter to current build then just auto passed on.


So the options are:
1.) Use System Groovy script to remote to the slave to grep the file for the string, and off and running.
2.) Use Groovy script to grep for string and hack to include class path so ParametersAction can be used to add new StringParameterValue.
3.) Use Groovy script to grep for string and simply output to file, then use EnvInject to read it back in as environment var.
4.) .... ??

Is there a preferred or standard method? Or something I'm not considering ...
Cheers

Ginga, Dick

unread,
Aug 12, 2015, 7:28:14 AM8/12/15
to jenkins...@googlegroups.com

I have only been able to get #3 to work. But I am not a Groovy expert. I would love a solution like #2 if you create one.

--
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-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/b3255169-67fb-42a0-b10d-00ca49d89e21%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Brantone

unread,
Aug 13, 2015, 3:37:08 AM8/13/15
to Jenkins Users
For the time being I ended up going with #1 using workspace.channel, as it was doing some very minor file modifications, although anything more complex and I'd probably go back to #3
#2 ended up being ridiculously hacky because ended up being case of whack-a-mole to get all the jars into the classpath and nearly found myself installing entire jenkins server onto the slave to do so. Part of me was hoping @Grab might solve it, but alas, no dice (per some tickets).

So, yeah, that's just the way it is :(

Khai Do

unread,
Aug 13, 2015, 12:31:39 PM8/13/15
to Jenkins Users

we do it with option #3 except instead of groovy we just use a simple bash script which is nice because every real system pretty much has bash.  
Reply all
Reply to author
Forward
0 new messages