【问题标题】:How to use SVN post-commit hook trigger jenkins build?如何使用 SVN post-commit hook trigger jenkins build?
【发布时间】:2020-01-23 07:41:58
【问题描述】:

主要目的是我想将一些文件提交到SVN存储库并触发jenkins自动构建一些测试。我想使用的方法是post-commit hook。

我使用 TortoiseSVN,并创建了一个存储库进行测试。 我将 post-commit.tmpl 更改为位于 D:\Repository\hooks 文件夹中的 post-commit.bat。

下面是 post-commit.bat 中的内容:(Windows 10)

SET REPOS=%1
SET REV=%2

FOR /f "tokens=*" %%a IN (
'svnlook uuid %REPOS%'
) DO (
SET UUID=%%a
)

FOR /f "tokens=*" %%b IN (
'svnlook changed --revision %REV% %REPOS%'
) DO (
SET POST=%%b
)

D:/Wget/wget ^
    --header="Content-Type:text/plain;charset=UTF-8" ^
    --post-data="%POST%" ^
    --output-document="-" ^
    --timeout=2 ^
    http://localhost:8080/jenkins/subversion/%UUID%/notifyCommit?rev=%REV%

错误信息是:

post-commit hook failed (exit code 8)with output:
--2019-09-23 13:50:53-- 
http://localhost:8080/"realUUID"/notifyCommit?rev=7
Resolving localhost(localhost)... ::1, 127.0.0.1
Connecting to localhost(localhost)|::1|:8080... connected.
HTTP request sent, awaiting response... 404 Not Found
2019-09-23 13:50:53 ERROR 404: Not Found

我所做的是: 1.将jenkins设置更改为“允许匿名读取访问” 2.取消CSRF保护

我不知道 SVN 与 Jenkins 通信的主要步骤是什么。

请帮忙,谢谢你的回答!

【问题讨论】:

    标签: jenkins svn post-commit-hook


    【解决方案1】:

    你收到的错误是HTTP 404 NOT FOUND,你需要检查你的钩子脚本是否有错误:

    HTTP request sent, awaiting response... 404 Not Found
    2019-09-23 13:50:53 ERROR 404: Not Found
    

    因此,wget 联系的 URL 无效http://localhost:8080/jenkins/subversion/%UUID%/notifyCommit?rev=%REV%。您需要仔细检查 URL 是否有拼写错误以及 %UUID% 是否正确。请注意,我在您的钩子中没有看到任何 %UUID% 的 SET - 也许是问题所在?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-13
      • 1970-01-01
      • 2012-07-27
      • 2013-01-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多