views:

64

answers:

1

I have separated a bug Hudson job into smaller jobs. Job A does the main build and Job B another build with different configuration. I configure Hudson, so that the A triggers B and it works fine. The problem is that Job A has the original build number and B just started from 1.

My question is: Is it possible to pass the BUILD_NUMBER environment variable somehow from Job A to Job B? The build number is used in the build artifact names, hence it would be nice to have the numbers match between artifacts.

Thanks.

+3  A: 

Use the parametrized Parameterized Trigger Plugin, which will allow you to pass the build number from A to B. You will not be able to actually set the build number in job B, but you will have the build number from A to generate your version number.

If you want to synchronize the build number, you can edit the file nextBuildNumber in the job directory to match the number from job A. Be aware that these numbers will drift apart over the time since when A fails B will not be started.

EDIT I just stumbled across the Next Build Number Plugin. Have a look, If this one helps you.

Peter Schuetze
Thanks Peter. I managed to the the BUILD_NUMBER passed to B from A pretty much as has been documented on the plugin front page. BUILD_NUMBER=${BUILD_NUMBER}. The env variable is the same in both projects.
J Andy
Editing the nextBuildNumber file didn't seem to have any effect, my changes are always overwritten. I can avoid the numbers being out of sync by triggering B even if A fails. That ofcourse makes B fail as well.
J Andy
The scenario is: A is successful, changes the nextBuildNumber-file and than needs to force Hudson to reload the configuration. This only needs to be done if A fails. If A doesn't fail, I am not sure if Hudson will reload the confif if another process runs.
Peter Schuetze
Thanks. I'll take a look at the plug-in.
J Andy