有条件地运行Jenkins中的svn修订版

时间:2014-02-04 16:43:19

标签: windows svn batch-file jenkins

以前,我让我的jenkins配置为仅运行最新的svn修订版。但是,我现在必须使它成为条件,就像我运行项目时,我应该选择我希望项目运行的svn_revision数字,如果我不选择svn修订版,那么它应该运行最新的

我添加了一个字符串参数,并尝试对项目进行参数化。

Configuration -> Add a parameter -> choose string parameter -> Name it as SVN_REVISION and some default value

Now in Execute windows batch command section:

Declare the svn revision parameter as:

REM Set SVN revison
SVN_REVISION = @${SVN_REVISION}

但是我仍然希望有能力,如果我不为这个参数选择任何值,它应该在最新版本上运行。但我不知道我们是否可以在jenkins批处理命令部分添加条件循环。有没有办法做到这一点?

1 个答案:

答案 0 :(得分:1)

您可以在Windows批处理文件中执行此操作

if "%SVN_REVISION%" == "" (
    set SVN_REVISION= "HEAD"
)

从这里改编Windows Batch Files: if else