I'm setting up my Subversion post-commit hook to trigger a Jenkins build remotely when a commit is made.
First I changed post-commit.tmpl
to post-commit.bat
and then:
I tried this first:
SET REPOS=%1
SET REV=%2
C:/wget_for_win/wget http://localhost:8080/jenkins/job/my_project/build
Then I committed some code, and it worked as expected.
But this will only build one project, but I want it more flexible so I changed post-commit.bat
to the one I found on the Jenkins Subversion Plugin page:
SET REPOS=%1
SET REV=%2
SET UUID=`svnlook uuid %REPOS%`
C:/wget_for_win/wget \
--header="Content-Type:text/plain;charset=UTF-8"
--post-data="svnlook changed --revision %REV% %REPOS%"
--output-document="-"
--timeout=2
http://localhost:8080/jenkins/subversion/%UUID%/notifyCommit?rev=%REV%
But this one doesn't work. It didn't trigger Jenkins to build any more. What did I do wrong in the second script?
I think the problem exists in running "svnlook" in the batch file. I run svnlook uuid [REPO LOCATION]
in cmd, and it shows the id. Then I put it in a batch file:
SET UUID=svnlook uuid [REPO LOCATION]
ECHO %UUID%
Running the above batch file doesn't output the id. It shows just svnlook uuid [REPO LOCATION]
.
Finally my
post-commit.bat
looks like:The post-commit hook is working now.