仅使用svn触发对干线的提交 [英] Only trigger a build on commits to the trunk with svn

查看:142
本文介绍了仅使用svn触发对干线的提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在我们的Subversion存储库中设置了一个提交后脚本,该脚本通过请求hudson构建URL来触发构建.

I have just set up a post-commit script in our subversion repository that triggers a build by requesting a hudson build URL.

这按预期工作正常,但是现在我只想在提交到主干时触发此构建.

This works fine as expected, however now I only want to trigger this build if the commit was to the trunk.

我们的提交后脚本如下:

our post-commit script looks like this:

SET REPOS=%1
SET REV=%2

SET DIR=%REPOS%/hooks
SET PATH=%PATH%;%DIR%
wget http://circus-09:8080/job/UE/build?delay=0sec

我如何检查提交是否在主干上?

How to I check that the commit was to the trunk?

推荐答案

下面是一个快速代码段,当中继中的某些内容更改或没有任何更改时,它会输出不同的消息:

Here's a quick code snippet, that outputs different messages when something in trunk changed or nothing has:

set repos=%~1
set rev=%~2

call :did_it_change "%repos%" "%rev%" "trunk"
if %ERRORLEVEL%==1 (
    echo trunk changed
) else (
    echo no changes in trunk
)
exit /B 0

:did_it_change
    set repos=%~1
    set rev=%~2
    set dir=%~3
    set found=0
    for /F "delims=/" %%p in ('svnlook dirs-changed "%repos%" -r %rev% 2^>NUL') do call :check "%%p" "%dir%"
    exit /B %found%

:check
    set check_string=%~1
    set must_match=%~2
    if "$%check_string%" == "$%must_match%" set found=1
    exit /B 0

请注意,:did_it_change函数可以与任何存储库根级子目录一起使用,而不仅仅是中继.非常有用,可以检测新的标签或分支.另外请注意,该函数可以调用任意次.

Note, that :did_it_change function can be used with any repository root level subdirectory and not just trunk. Very useful, to detect new tags or branches. Also note, that the function can be called any number of times.

注意:这实际上并不检查源文件是否已更改-它只是检查修订的已更改目录列表中是否提到了中继.可能是更改了某些目录或文件的svn属性.

Note: This doesn't actually check if source files were changed or not - it simply checks if trunk is mentioned in the revisions changed directories list. It could be that the change was to the svn attributes of some directories or files.

这篇关于仅使用svn触发对干线的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆