How can I checkout different Subversion tags/branches of the same Java project while using Ant/Jenkins?

不打扰是莪最后的温柔 提交于 2019-12-04 10:26:09

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}).

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!