views:

153

answers:

1

Day 1 with using Hudson for our CI build. Slowly but surely getting up to speed.

My question is about run parameters. I've seen that I can use them to reference a particular run of a particular project - that's all fine.

What I don't understand (and can't find any documentation on - there's nothing at Parameterized Build) is how I refer to anything in the run defined by the run parameter.
Essentially I want to reference the %BUILD_NUMBER% and %SVN_REVISION% of the run that is selected in the run parameter.

How can I do that?

+2  A: 

Do you really need to add extra property values, extra parameters for your job?

Since BUILD_NUMBER and SVN_REVISION are already defined as environment variables (see Building a software project), you can use those in your job.

When a Hudson job executes, it sets some environment variables that you may use in your shell script, batch command, or Ant script

alt text

or:

alt text

illustrates you already have those values at your disposal.
You can then use them to define other environment variables/properties within your shell or ant script.


When it comes to pass a variable value from one job to another, the Parameterized Trigger Plugin should do the trick:

The parameters section can contain a combination of one or more of the following:

alt text

  • a set of predefined properties
  • properties from a properties file read from the workspace of the triggering build
  • the parameters of the current build
  • "Subversion revision": makes sure the triggered projects are built with the same revision(s) of the triggering build.
    You still have to make sure those projects are actually configured to checkout the right Subversion URLs.

Note: there might be an issue with the Join Plugin, which might not work when the Parameterized Trigger is in action.

VonC
I think that is an Answer that you can accept. The page explains it good enough.
Peter Schuetze
Thanks, but that won't work (I don't think).I'll explain. We have 2 Hudson jobs. One of them (let's call it buildJob) does a build and the second (let's call it deployJob) basically deploys the output of that first job.buildJob dumps its output into a folder called:%KNOWN_FOLDER_LOCATION%\%BUILD_NUMBER%.%SVN_REVISION%Hence deployJob needs to know what the SVN_REVISION number of a given run of buildJob was.Hope that makes sense. If we're not doing the "normal" way then so be it, though we're too far down the path to restructure now.Any comments most welcome.-Jamie
jamiet
@jamiet: why not saving those variables in a file (like a kind of '`.properties`' file) at the end of the first job, and read them at the beginning of the second?
VonC
VonC,Yep, that's what we're doing currently. I was just hoping I could do something a bit "cleaner" y'know. No worries if not, thanks for the replies. [[Still would like to understand run params a bit better tho]]
jamiet
@jamiet: note, the [Parameterized Trigger Plugin](http://wiki.hudson-ci.org/display/HUDSON/Parameterized+Trigger+Plugin) might interest you, in order to pass variables from one build to another.
VonC
Nice. thanks Von.
jamiet
@jamiet: I have updated my answer to include the Parameterized Trigger Plugin.
VonC
Yup, saw that Von, thank you. And thank you so much for taking the time to provide some great replies. Muchos apprecios!
jamiet