Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trouble with SVN post-commit and Jenkins

I am trying to get CI going with Jenkins. To date, we have been performing two scheduled builds in our environment, but our dev staff wants to get CI working. I have followed the instruction outlined in the Jenkins Subversion Plugin wiki page:

https://wiki.jenkins-ci.org/display/JENKINS/Subversion+Plugin

This got me to a script that executes at the command line just fine, however when I commit a change in Subversion (using the TortoiseSVN client), the commit seems to hang and I don't see Jenkins getting notified.

Here is my script:

#!/bin/sh

REPOS="$1"
REV="$2"
UUID=`svnlook uuid $REPOS`
XSLT_FILE=/var/www/svn/codelog.xslt
RSS_FILE=/var/www/html/code_all.rss
MAX_RESULTS=40

/usr/bin/wget \
  --auth-no-challenge \
  --no-check-certificate \
  --header "Content-Type:text/plain;charset=UTF-8" \
  --post-data "`svnlook changed --revision $REV $REPOS`" \
  --output-document "-" \
  --timeout=2 \
  https://192.168.100.16/subversion/${UUID}/notifyCommit?rev=$REV
svn log "file://$REPOS" --limit "$MAX_RESULTS" -v --xml | xsltproc "$XSLT_FILE" - > "$RSS_FILE"

The RSS feed was already in the script. That has been working for over a year.

I have updated the file permissions as well, in case that was the problem:

[root@Subversion hooks]# ls post-commit -ao
-rwxrwxr-x 1 apache 530 Jul 17 06:27 post-commit
like image 361
jarhorn Avatar asked Jul 17 '12 11:07

jarhorn


People also ask

How to use Jenkins with SVN to build a project?

Select Jenkins from the left menu and then Manage Plugin tab, we need this plugin to build our C# project because in our case, after getting the updates from SVN, we will be using DLL files to run out automation scripts (of course with many other files which we will be known in later steps).

How to take updates from the SVN?

Thirdly, you will have to write the batch commands in order to take the updates from the SVN, then build the project, copy the respective needed files and then finally copy the files you required in the respective folders. I will be explaining each command separately, rather it will be more helpful if you know the basics of writing batch command.

How to create a Jenkins job?

Firstly, you need to create a fresh Jenkins Job, give it a relevant name, and write the description of the job stating what you want to do inside this job, just for future reference for the people who will be modifying the job later on. Now, here is the description of the job and the steps it tends to perform.

Which version control system should I use with Jenkins?

For the sake of achieving my target I’ve used SVN as a version control throughout the article, you can use any of the version control systems according to your requirements since there are no boundaries Jenkins demands to work with for the version control system; furthermore, there is one thing to keep in mind, which is that you need to install ...


2 Answers

In order to enable push mode in Jenkins, you should enable the Poll SCM build trigger in configuration page of your job. It tells Jenkins that it should build the job whenever SCM changes occur.

Because you don't have to do any polling (you get the info from the hook) you can leave the field blank.

like image 193
Yossi Avatar answered Oct 11 '22 17:10

Yossi


Please take a look at your URL. Since Jenkins is a web application running in a servlet container the following one must work:

http(s)://server_name:server_port/application_name/subversion/${UUID}/notifyCommit?rev=$REV"

The idea is to pass

"subversion/${UUID}/notifyCommit?rev=$REV"

to the right place.

like image 39
sinner Avatar answered Oct 11 '22 17:10

sinner