Subversion Plugin

This plugin adds the Subversion support (via SVNKit) to Hudson. This plugin is bundled inside hudson.war if you download it from hudson-ci.org.

Plugin Information

Plugin ID subversion
Latest Release 1.17
Latest Release Date Apr 21, 2010
Changes via Fisheye In Latest Release
Since Latest Release
Maintainer(s) Many (id: kohsuke abayer dodok1 dty huybrechts mindless pgweiss stephenconnolly etc)
Issue Tracking Open Issues

Basic Usage

Once this plugin is installed, you'll see Subversion as one of the options in the SCM. See inline help for more information about how to use it.

Usage with Server Certificates

An important note for those wanting to use client certificates to authenticate to your subversion server.   Your PKCS12 cert file must not have a blank passphrase or a blank export password as it will cause authentication to fail.    Refer to SVNKit:0000271 for more details.

Advanced Features/Configurations

Post-commit hook

Hudson can poll Subversion repositories for changes, and while this is reasonably efficient, this can only happen up to every once a minute, so you may still have to wait a full minute before Hudson detects a change.

To reduce this delay, you can set up a post commit hook so the Subversion repository can notify Hudson whenever a change is made to that repository. To do this, put the following script in your post-commit file:

REPOS="$1"
REV="$2"
UUID=`svnlook uuid $REPOS`
/usr/bin/wget \
  --header "Content-Type:text/plain;charset=UTF-8" \
  --post-data "`svnlook changed --revision $REV $REPOS`" \
  --output-document "-" \
  http://server/hudson/subversion/${UUID}/notifyCommit?rev=$REV
Jobs on Hudson need to be configured with the SCM polling option to benefit from this behavior. This is so that you can have some jobs that are never triggered by the post-commit hook, such as release related tasks, by omitting the SCM polling option.
The configured polling can have any schedule (probably infrequent like monthly or yearly). The net effect is as if polling happens out of their usual cycles.
For this to work, your Hudson has to allow anonymous read access to the system. If access control to your Hudson is more restrictive, you may need to specify the username and password, depending on how your authentication is configured.
If your Hudson uses the "Prevent Cross Site Request Forgery exploits" security option, the above request will be rejected with 403 errors ("No valid crumb was included"). The crumb needed in this request can be obtained from the URL http://server/hudson/crumbIssuer/api/xml (or /api/json). This can be included in the wget call above with something like this:
--header `wget -q --output-document - \
  'http://server/hudson/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)'`

Windows specific post-commit hook

The above script is difficult under the Windows command processor seeing as there is no support for backtick output extraction and there is no built in wget command. Instead the following contents can be added to post-commit.bat:

SET REPOS=%1
SET REV=%2
SET CSCRIPT=C:\WINDOWS\system32\cscript.exe
SET VBSCRIPT=C:\Repositories\post-commit-hook-hudson.vbs
SET SVNLOOK=C:\Subversion\svnlook.exe
SET HUDSON=http://server/hudson/
"%CSCRIPT%" "%VBSCRIPT%" "%REPOS%" %2 "%SVNLOOK%" %HUDSON%

The batch file relies on the following VBScript being available in the file designated by the VBSCRIPT variable above:

repos   = WScript.Arguments.Item(0)
rev     = WScript.Arguments.Item(1)
svnlook = WScript.Arguments.Item(2)
hudson  = WScript.Arguments.Item(3)

Set shell = WScript.CreateObject("WScript.Shell")

Set uuidExec = shell.Exec(svnlook & " uuid " & repos)
Do Until uuidExec.StdOut.AtEndOfStream
  uuid = uuidExec.StdOut.ReadLine()
Loop
Wscript.Echo "uuid=" & uuid

Set changedExec = shell.Exec(svnlook & " changed --revision " & rev & " " & repos)
Do Until changedExec.StdOut.AtEndOfStream
  changed = changed + changedExec.StdOut.ReadLine() + Chr(10)
Loop
Wscript.Echo "changed=" & changed

url = hudson + "subversion/" + uuid + "/notifyCommit?rev=" + rev
Wscript.Echo url

Set http = CreateObject("Microsoft.XMLHTTP")
http.open "POST", url, False
http.setRequestHeader "Content-Type", "text/plain;charset=UTF-8"
http.send changed

Change Log

Version 1.17 (Apr 21, 2010)

  • Failure to retrieve remote revisions shouldn't result in a new build (issue #6136)
  • Updated German & Japanese localization.
  • Fixed that "svn log copier thread" is nerver destoryed if exception is thrown while checking out.(issue #6144)

Version 1.16 (Mar 23, 2010)

  • Fixed issue #6030, where the new includedRegions feature broke the excludedRegions.

Version 1.15 (Mar 22, 2010)

  • Added Spanish translation.

Version 1.14 (Mar 17, 2010)

  • Add includedRegions feature, analogous to the excludedRegions feature (issue #5954).

Version 1.13 (Mar 8, 2010)

  • Fixing polling for projects where last build was run on Hudson 1.345+ with Subversion plugin 1.11 or older (issue #5827)

Version 1.12 (Mar 3, 2010)

  • Polling period can be set shorter than the quiet period now. (issue #2180)
  • Exposed properties to the remote API. (report)
  • Validation for "excluded users" field was too restrictive. (issue #5684)
  • Avoid ClassCastException in change log computation if job SCM is changed from Subversion to something else. (issue #5705)

Version 1.11 (Feb 11, 2010)

  • Allow commit comment to be provided when tagging. (issue #1725)
  • Fix display of existing tags when there are multiple repositories.
  • Minor updates to aid in debugging problems triggering jobs from a post-commit hook.

Version 1.10 (Jan 27, 2010)

  • SSL client certificate authentication was not working (issue #5349)
  • Make all links from help text open a new window/tab, to avoid leaving the config page when there are unsaved changes (issue #5348)
  • Export tag information via remote API (issue #882)

Version 1.9 (Jan 16, 2010)

  • SSL client certificate authentication was not working (issue #5230)
  • Tagging UI allows users to specify one-time credential for tagging (issue #2053)
  • Fix a bug in the notifyCommit post-commit hook wrt a commit spanning multiple jobs (issue #4741)

Version 1.8 (Dec 23, 2009)

  • Polling can now ignore commits based on configurable keywords in the commit messages. (patch)
  • Several minor bug fixes

Version 1.7 (Sep 3, 2009)

  • Fixed a bug in the exclusion pattern matching
  • Fixed a bug in an interaction with the Trac plugin.
  • Fixed a bug in the interaction of concurrent builds and Subversion polling (issue #4270)

Version 1.6 (Aug 28, 2009)

Version 1.5 (Aug 19, 2009)

  • Polling is performed on the slaves now (report)
  • "Tag this Build" fails for 1.311+ with SVN Plugin (issue #4018)

Version 1.3 (July 8, 2009)

  • Subversion checkouts created files for symlinks (issue #3949)

Version 1.2 (June 24, 2009)

  • Fixed "endless authentication to SVN when invalid user/password" issue (issue #2909)

Version 1.0 (June 15, 2009)

Labels:

plugin-scm plugin-scm Delete
Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.
  1. Dec 30, 2009

    Dan Morrow says:

    I'm trying to build a specific revision. The help says: You can also add "@NNN"...

    I'm trying to build a specific revision. The help says:

    You can also add "@NNN" at the end of the URL to check out a specific revision number, if that's desirable

    So, I set the URL to be: "https://mycompany.com/svn/SpecialProject/trunk@12345" to indicate revision 12345. Well, I'm doing that, and Hudson says: '/SpecialProject/trunk@12345' doesn't exist in the repository. Maybe you meant '/SpecialProject/trunk'?

    Is there a better way to specify a revision when doing an update from Subversion, or is this bug?

    1. Jan 06, 2010

      Yossi Zach says:

      AFAIK, it is a bug. You should just ignore the message. After saving the settin...

      AFAIK, it is a bug. You should just ignore the message.

      After saving the settings Hudson will checkout the requested revision all the same.

  2. Feb 15

    Herve Quiroz says:

    Just some extra information for those using LDAP authentication. I had some trou...

    Just some extra information for those using LDAP authentication. I had some trouble configuring the post-commit hook (403 error: authentication failure with wget). I found out the following solution:

    1. retrieve a persistent authentication cookie:

    $ wget \
      --save-cookies /path/to/hudson-authentication-cookie \
      --output-document "-" \
      'http://server/hudson/j_acegi_security_check?j_username=<username>&j_password=<password>&remember_me=true'
    

    (with <username> and <password> related to an existing and valid account in your LDAP server)

    2. add the following as the post-commit hook:

    REPOS="$1"
    REV="$2"
    UUID=`svnlook uuid $REPOS`
    /usr/bin/wget \
      --header "Content-Type:text/plain;charset=UTF-8" \
      --post-data "`svnlook changed --revision $REV $REPOS`" \
      --output-document "-" \
      --load-cookies /path/to/hudson-authentication-cookie \
      http://server/hudson/subversion/${UUID}/notifyCommit?rev=$REV
    
    1. Mar 11

      Mark Lewis says:

      For those using Windows, the same thing can be accomplished by adding an Authori...

      For those using Windows, the same thing can be accomplished by adding an Authorization request header to the last part of the VBScript. Just encode "<username>:<password>" in base64 for the value.

      Set http = CreateObject("Microsoft.XMLHTTP")
      http.open "POST", url, False
      http.setRequestHeader "Content-Type", "text/plain;charset=UTF-8"
      http.setRequestHeader "Authorization", "Basic dXNlcm5hbWU6cGFzc3dvcmQ="
      http.send changed
  3. Mar 19

    Felix Petriconi says:

    According to my experience with version 1.351 the URL in the shell script must b...

    According to my experience with version 1.351 the URL in the shell script must be a little bit different:

    http://server/subversion/${UUID}/notifyCommit?rev=$REV
    

    so without the "hudson/" part in the path.

    1. Mar 20

      Yossi Zach says:

      It depends on the Hudson installation. When Hudson running in it's default conta...

      It depends on the Hudson installation. When Hudson running in it's default container it is running on the domain root and it does not requires the hudson/ prefix.

      In more general case when Hudson is running within another container you will need the stated prefix.

  4. Apr 26

    David Aldrich says:

    Version 1.17 is not appearing in Hudson's Plugin manager's 'Updates' tab as of 2...

    Version 1.17 is not appearing in Hudson's Plugin manager's 'Updates' tab as of 26 April 2010.

  5. Apr 27

    Jaakko Aro says:

    Would it be possible to have an option that this plugin does not store auth cach...

    Would it be possible to have an option that this plugin does not store auth cache to .subversion/auth/svn.simple ?

    I'm thinking a way that on could configure the plugin to all project that it always runs like (for example) svn co https://here.is.url.to.svn/trunk --no-auth-cache --username foo --password bar

    So all authentication data would be stored in some hudson / plugin configuration file and there would be no need to access the home -folder.

    This feature would really help us since we have almost 1000 builds using svn and the home -folder is mounted trough NFS. Sometimes the NFS doesn't reply fast enough so the plugin can't read the data from  ~/.subversion/auth/svn.simple and the build fails for no reason..

  6. May 05

    Axel Heider says:

    In a DOS batch, you can do this to get command output in a variable without usin...

    In a DOS batch, you can do this to get command output in a variable without using a tmp file:

    set _TMP_CMD=svnlook uuid %REPO%
    set _TMP_VAR=UUID
    FOR /F "tokens=1 delims=" %%A in ('%_TMP_CMD%') do set %_TMP_VAR%=%%A
    echo UUID is [%UUID%]
    

    However, the whole POST request could get too big ich many files have changes. Thus I wonder, why a simple GET-request with

    http://server/hudson/subversion/${UUID}/notifyCommit?rev=${REV}
    

    would be enough. Hudson get the file list internally as well, as it gets the new revision number anyway.

    What does Hudson do when I send one POST request per changed file in the post-commit hook?

    would be the side-