How to pass hudson environment variable as parameter for svn build

My requirement: I need the Hudson environment in the subproject build option for the svn url.

I want to set the SVN branch name as the environment variable for Hudson, since I want it to be used by all of my projects configured there.

If I access my environment variable [BUILD_BRANCH] as

http: // svn / repos / project / subproj / branches / $ {BUILD_BRANCH}

URL is not replaced with a value.

But in the same case, if I have BUILD_BRANCH as a String Parameter for Parameterized Build, in each routine the url is replaced with a value. But I can’t change the branch value [assembly parameter value] every time in all projects. In addition, downstream projects were not able to access the assembly parameters of the [String] calling projects.

+6
branch svn build hudson
source share
4 answers

There is a flag in the assembly configuration: "This assembly is parameterized."

If you enable this, you can create parameters for this particular assembly.

I hope this helps.

+1
source share

Let me clarify your problem. You have defined the BUILD_BRANCH environment variable and want to be able to refer to it from a parameter for your assembly. Is it correct?

If this is the case, then I solved your problem!

When the parameters are evaluated (and any variables associated with them are expanded), you do not have access to the environment variables, so the parameter value ends with the letter "$ {BUILD_BRANCH}", and is not expanded to the $ BUILD_BRANCH environment definition.

Then, when you reference a parameter from a shell script, the parameter value is surrounded by single quotes, which prevents the removal of an extra layer of indirection, so you get the name of your environment variable, not its value.

The solution is to add eval to the beginning of each line of the shell script, where you refer to a parameter that will allow an extra level, and the variable will work.

Last: you do not need to do this if you are referencing the previous parameter. Therefore, if Param1 is foo and Param2 is $ {foo} bar, this will work because the parameters are evaluated in order. However, if the parameter values ​​have been switched, you will need to use eval.

0
source share

There seems to be no current way to use the environment variable to set the location of the subversion repository. What I decided to do was edit the config.xml files from the outside using a script.

This may not work for you if the value of this variable changes programmatically, but for us, I would like to transfer our tasks between the branches and the trunk that each sprint runs and is a manual process.

There is some kind of script for us, as shown below:

 FROM_SVN_PATH="svnserver.com/trunk" TO_SVN_PATH="svnserver.com/branches/1.1" cd jobs for f in */config.xml do sed -e "s,$FROM_SVN_PATH,$TO_SVN_PATH," < "$f" > "$ft" mv "$f" "$f.ORG" mv "$ft" "$f" done 

If you are using Jenkins, you can go to "Manage Jenkins" and select "Reboot configuration from disk."

0
source share

set BUILD_BRANCH in ManageHudson-> Configure System-> Global properties-> Environment Variables

-one
source share

All Articles