views:

39

answers:

1

Hi,

I have a Hudson job that runs a maven goal. Before this maven goal is executed I have added a step to run before the build starts, it is a shell script that obtains the version number that I want to use in the 'Goals and options' field.

So in my job configuration, under Build Environment I have checked the Configure M2 Extra Build Steps box and added a shell script before the build. The script looks like this:

export RELEASE={command to extract release version}
echo $RELEASE

And then under the Build section I point to my 'root pom'. In the Goals and options I then want to be able to do something like this:

-Dbuild.release.version=${RELEASE} deploy

Where build.release.version is a maven property referenced in the POM. However since the shell doesn't seem to make its variables global it doesn't work. Any ideas?

The only one I have is to install the Envfile plugin and get the shell script to write out the RELEASE property to a file and then get the plugin to read the file, but the order in which everything is run may cause problems and it seems like there must be simpler way...is there?

Thanks in advance.

A: 

When you say it doesn't work, do you mean that your RELEASE variable is not passed to the maven command? I believe the problem is that by default, each line of the shell script is executed separately, so environment variables get lost.

If you want the entire shell script to execute as if it was one script file, make the first line:

#!/bin/sh

I think this is described in the Help information alongside the shell script build step (and if I'm wrong, that's a good place to look for the right syntax).

Dave Bacher
Hi, thanks for the reply - I tried that but get the error:Building on master[workspace] $ /bin/sh c:\DOCUME~1\usr\LOCALS~1\Temp\1\hudson5860957589544318456.shFATAL: command execution failedjava.io.IOException: Cannot run program "/bin/sh" (in directory "E:\hudson\jobs\MyJob\workspace"): CreateProcess error=3, The system cannot find the path specified at java.lang.ProcessBuilder.start(ProcessBuilder.java:459) ... Caused by: java.io.IOException: CreateProcess error=3, The system cannot find the path specified at java.lang.ProcessImpl.create(Native Method) ...Ran on a windows box
Ed
Think I understand it now- http://hudson.361315.n4.nabble.com/sh-in-cygwin-td368129.html
Ed
Yep, still doesn't work. Using version 1.371 of Hudson
Ed