问题
Here is my dev configuration:
Under Subversion,
- I have my project_X/trunk (with my latest dev),
- I have my project_X/tags (with different releases),
- I am thinking of adding a branch folder.
I am using Jenkins to build my project_X/trunk using an Ant script. My Ant script does many things, it checks-out, compiles, creates the documentation with graphs, runs the unit tests, performs pmd, creates a jar and zips everything.
I would like to be able to use my Ant script on tags or branches (as well as the trunk) for the same Project.
What's the easiest way to do this:
I think it is just a question of checking out the right path to the Subversion repository, Right?
- If I am correct, I should make the path to the Subversion dynamic.
- In my Ant script should my Subversion path be a variable?
- How do I pass the path value from Jenkins' interface?
- Is there a plugin that lets me pass the Subversion path value from Jenkins to the Ant script?
- Or should I just create a new job in Jenkins (with the same script but different path)?
Hope
Thanks in advance for your help,
Best regards,
回答1:
You should parameterize your build by tag/branch name. The easiest way to do it is to add a parameter (say, SVN_BRANCH_DIR) to your Jenkins job which will have values such as trunk
, branches/branch1
, tags/sometag
.
Now, if you use Jenkins ANT build step that parameter will be passed automatically to your ANT script as a property (by way of ANT -D
option). So you can use ${SVN_BRANCH_DIR}
in it (e.g. svn://myserver/myrepo/${SVN_BRANCH_DIR}
).
回答2:
Jenkins Subversion Plugin provides a "List subversion tags (and more)" project parameter since Version 1.24 (Mar 22, 2011).
Literally,
When used, this parameter will display a field at build-time so that the user is able to select a Subversion tag from which to create the working copy for this project. Once the two fields Name and Repository URL are set, you must (1) ensure the job uses Subversion and (2) set the Repository URL field of Subversion by concatenating the two fields of this parameter. For instance, if Name is set to SVN_TAG and Repository URL is set to https://svn.jenkins-ci.org/tags, then Subversion's Repository URL must be set to https://svn.jenkins-ci.org/tags/$SVN_TAG. Notice that you can set the Repository URL field to a Subversion repository root rather than just pointing to a tags dir (ie, you can set it to https://svn.jenkins-ci.org rather than https://svn.jenkins-ci.org/tags). In that case, if this repository root contains the trunk, branches and tags folders, then the dropdown will allow the user to pick the trunk, or a branch, or a tag.
For unattended integration builds you could use the default "trunk" parameter value.
I hope this helps.
来源:https://stackoverflow.com/questions/11011358/how-can-i-checkout-different-subversion-tags-branches-of-the-same-java-project-w