View Source

{excerpt}This plugin adds the Subversion support (via SVNKit) to Hudson.{excerpt}
{hudson-plugin-info:pluginId=subversion}
{toc:maxLevel=2}
h1. 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.

h3. Specifying Authorization

The credentials for Subversion authorization are used from three places

* System wide global
* Hudson wide global
* Hudson Job specific

If you don't specify any SVN credentials in Hudson, Subversion plugin tries to use the System wide Global (usually something like /home/janedoe/.subversion).  Otherwise a link is provided in the error message  as shown below

!svn_auth1.png!

Clicking on the "enter credential" link take you to a page where you can enter credentials.


  !svn_auth2.png!

If you specify the SVN credentials in Hudson and select yes for "override global credentials", then the SVN credential is stored in the job directory, this credential is specific to SVN configuration in that Job. Otherwise the credential will be stored as Hudson global, so that any job in Hudson with SVN configuration can be authenticated with that credential.
 

If you configure the job second time, now the SVN URL displays a link that says "Update Credential"

h3. !svn-auth3.png!


h3. 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|http://svnkit.com/tracker/view.php?id=271|SVNKit:0000271] for more details.


h1. Advanced Features/Configurations


h2. 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|http://svnbook.red-bean.com/en/1.5/svn.reposadmin.create.html#svn.reposadmin.create.hooks] 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:

*Using wget*

{noformat}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 "-" \
--timeout=2 \
http://localhost:8080/subversion/${UUID}/notifyCommit?rev=$REV
{noformat}
*Using curl*

{noformat}REPOS="$1"
REV="$2"

UUID=`svnlook uuid $REPOS`
/usr/bin/curl \
--header "Content-Type:text/plain;charset=UTF-8" \
--data "`svnlook changed --revision $REV $REPOS`" \
http://localhost:8080/subversion/${UUID}/notifyCommit?rev=$REV
{noformat}


{note}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.
{note}
{info}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.
{info}
{info}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:
{noformat}--header `wget -q --output-document - \
'http://server/hudson/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)'`{noformat}
{info}
h3. 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}}:

{noformat}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%" %REV% "%SVNLOOK%" %HUDSON%
{noformat}The batch file relies on the following VBScript being available in the file designated by the {{VBSCRIPT}} variable above:
{noformat}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
{noformat}
h3. Build with Tags

If you would like to build hudson with a specific tag you can do the following:
Scenario example:
Tag URL: [https://hudson.dev.java.net/svn/hudson/tags]

Under the project, click on the option "This build is parameterized". Next click the Add parameter dropdown and select the "List Subversion Tags" option.
!svn tag parameter.png!
For the name keep it simple like SVN_TAG. For the Repository URL set it to the URL: [https://hudson.dev.java.net/svn/hudson/tags]. The next step is to go under the Subversion plugin options. Under the Repository URL for the Subversion plugin:
!scm tag.png!
As you can see in this picture we use the $SVN_TAG variable. That should work, just click save and execute a build.

h2. Perform Polling from the Master

JIRA [5413@issue] documents problems with running the SCM polling trigger on slaves. Version 1.21 of the Subversion plugin can perform the polling on the Hudson master if the hudson.scm.SubversionSCM.pollFromMaster system property is set to true.

h2. Subversion Revision and URL information as Environment Variables

The Subversion SCM plugin has always exported $SVN_REVISION and $SVN_URL as long as your project only has one module location configured. With version 1.21 of the plugin, additional environment variables are available for projects that define multiple module locations. $SVN_REVISION_n and $SVN_URL_n are exported, where n is the 1-based index of the module in the configuration.

h2. Kerberos authentication

To connect to a Kerberos authenticated SVN repository see the [Subversion Plugin HTTPS Kerberos authentication] page.

h1. TroubleShooting


Someone suggested in the Hudson IRC channel that if you are getting an error and a long svnkit stack trace that looks like:
{noformat} ERROR: svn: authentication cancelled

org.tmatesoft.svn.core.SVNCancelException: svn: authentication cancelled
{noformat}Then,
* Try to delete (back up) the \~/.subversion folder and retry the build. Apparently mixing the command line svn client checkouts with those of your Hudson jobs messes it up.
* See [http://blog.vinodsingh.com/2009/08/hudson-svn-authentication-cancelled.html] for details.

h1. Change Log

h3. Version 2.3.10 (Aug 5, 2014)

* Upgrade to svnkit 1.8.5
* 438400 - 1.8 Is not a permitted Subversion Workspace Version in Manage Hudson
* 439300 - Selecting "Subversion Workspace Version" 1.7 checks-out workspace as 1.8

h3. Version 2.3.9 (June 26, 2014)

* Upgrade to svnkit 1.8.3-1
* Add possibility to ignore notifications from post-commit hooks

h3. Version 2.3.8 (February 15, 2012)

Improvements -
Add ability to use global variables in SVN Url.
Add cleaner message when authentication fails.

Bugs\-
399165 - Issue with svn post-commit hook.
Fixed issue from email thread [http://dev.eclipse.org/mhonarc/lists/hudson-dev/msg00374.html]

h3. Version 2.3.7 (Jan 23, 2012)

* Fix eclipse bug 390648.
** Test units only - Added port checker for svnserve.

h3. Version 2.3.6 (Dec 03, 2012)

* Fix issue with noclassdef found exception.

h3. Version 2.3.5 (Nov 26, 2012)

* Added svnswitch option (Thanks ofer_zelichover)
* Fix Eclipse bug 388344.
* Fix serialization issue with SVNUrl class.

h3. Version 2.3.4 (Sep 14, 2012)

* SVN::Web support (Thanks Michael Vitz)
* Fix eclipse bug 387673. (Upgrade to svnkit 1.7.5)

h3. Version 2.3.3 (Jul 10, 2012)

* Added svn 1.7 workspace option
* Fail build when file locked instead of fresh checkout.

h3. Version 2.3.2 (May 29, 2012)

* Fix issue with storing svn credentials per job.

h3. Version 2.3.1 (May 17, 2012)

* Upgrade to svnkit 1.7.4 for official svn 1.7 support.
* Fix Eclipse bug 376042.

h3. Version 2.3.0 (Mar 23, 2012)

* Upgrade to svnkit 1.3.7 for support with svn 1.7.
* Major code cleanup and security fix.

h3. Version 2.2.0_1 (Nov 30, 2011)

* Implemented: SVN list tags ordering, descending based on svn revision number ([9036@issue])
* Fixed: Subversion Polling Log serialize error after upgrade to subversion-plugin ([8982@issue])

h3. Version 2.2.0 (Oct 26, 2011)

* Improved code style, added unit tests, implemented equals and hashcode methods required for [Project cascading|http://wiki.hudson-ci.org/display/HUDSON/Project+cascading] feature.
* Implemented subversion.credentials loading from the cascading parent projects.
* Improved svn credentials searching in case of matrix project.
* Updated hudson parent to 2.2.0.

h3. Version 2.1.2 (Oct 7, 2011)

* Updated svnkit to 1.3.5
* Updated hudson parent to 2.1.2.
* Patched hudson.util.Digester2 was replaced with org.apache.commons.digester3.Digester.

h3. Version 2.1.1 (Sep 2, 2011)

* Fixed: '/' is added incorrectly before '?' in WebSvn url ([5060@issue])
* Fixed: SCM polling always return true when using specific revision in svn ([8554@issue])
* Fixed: Builds aborted during SVN update are marked as FAILURE ([4605@issue])
* Fixed: SVN fails to checkout in Matrix Jobs in Hudson 2.1.0 [(issue #3)|http://java.net/jira/browse/HUDSON-3]
* Improved PerJobCredentials handling. Use repo url without revision number for credentials key.

h3. Version 2.1.0 (July 27, 2011)

* Fixed: User name vs username  ([8922@issue])
* Fixed: Excluded Users field with subversion doesn't accept users with dash \(-) in name ([8700@issue])
* Fixed: Subversion changes are listed multiple times ([2344@issue])
* Improved layout and fixed some grammar problems
* Changed maven groupId to "org.hudsonci.plugins"

h3. Version 2.0.1 (June 2, 2011)

* Fixed: Subversion plugin fails to render ChangeSet ([8837@issue])
* Fixed: Workspace deleted when subversion checkout happens ([3580@issue])
* Fixed: Setting SVN credentials for a job should not require administer permission ([8841@issue])
* Fixed: Subversion Plugin failed while checking out ([7804@issue])
* Fixed: Change set always shows "No changes" ([8852@issue])

h3. Version 2.0.0 (May 3, 2011)

* Added a new job parameter allowing to dynamically list svn tags
* Added Japanese localization
* Fixed form validation error whenever @revision was entered. Added revision validation
* Fixed Subversion Plugin does break native svn command line authentication, credentials missing after rewriting auth cache file ([8059@issue])
* The need for Subversion command line options ([777@issue])
* Resolve issue with overriding credentials during build execution from slave node
* Add option to clean workspace before each build ([3966@issue])
* Force using HEAD SVN version for build. Added combobox for revision policy ([1241@issue])

h3. Version 1.23 (Jan 6, 2011)

* Introduced a new extension point to control the checkout behaviour.
* Added a new checkout strategy that emulates "svn checkout" by "svn update" + file deletion.
* Fixed revision number pinning problem ([8266@issue])
* Fixed a per-job credential store persistence problem ([8061@issue])
* Fixed a commit notify hook problem with Jetty ([8056@issue])

h3. Version 1.22 (Dec 10, 2010)

* Support revision keywords such as HEAD in repository URL configurations.
* Fixed StringOutOfBoundException. ([8142@issue])
* Fixed "Unable to locate a login configuration" error with Windows Subversion server ([8153@issue])

h3. Version 1.21 (Nov 18, 2010)

* Expose Subversion URL and revision information for all modules in environment variables ([3445@issue])
* Added system property to control whether SCM polling runs on the Hudson master or on slaves ([5413@issue])
* Make sure stored credentials have restricted file permissions

h3. Version 1.20 (Nov 1, 2010)

* Fixed a serialization issue.

h3. Version 1.19 (Oct 29, 2010)

* Fixed a configuration roundtrip regression introduced in 1.18 ([7944@issue])
* Supported svn:externals to files ([7539@issue])

h3. Version 1.18 (Oct 27, 2010)

* *Requires Hudson 1.375 or newer.*
* Builds triggered via the post-commit hook check out from the revision specified by the hook. The hook specifies the revision with either the rev query parameter, or the X-Hudson-Subversion-Revision HTTP header.
* Uses svnkit 1.3.4 now. ([6417@issue])

h3. Version 1.17 (Apr 21, 2010)

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

h3. Version 1.16 (Mar 23, 2010)

* Fixed [6030@issue], where the new includedRegions feature broke the excludedRegions.

h3. Version 1.15 (Mar 22, 2010)

* Added Spanish translation.

h3. Version 1.14 (Mar 17, 2010)

* Add includedRegions feature, analogous to the excludedRegions feature ([5954@issue]).

h3. 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 ([5827@issue])

h3. Version 1.12 (Mar 3, 2010)

* Polling period can be set shorter than the quiet period now. ([2180@issue])
* Exposed properties to the remote API. ([report|http://n4.nabble.com/Question-on-Hudson-API-td1566592.html#a1566592])
* Validation for "excluded users" field was too restrictive. ([5684@issue])
* Avoid ClassCastException in change log computation if job SCM is changed from Subversion to something else. ([5705@issue])

h3. Version 1.11 (Feb 11, 2010)

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

h3. Version 1.10 (Jan 27, 2010)

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

h3. Version 1.9 (Jan 16, 2010)

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

h3. Version 1.8 (Dec 23, 2009)

* Polling can now ignore commits based on configurable keywords in the commit messages. ([patch|http://www.nabble.com/patch-for-subversion-plugin-to-add-exclusion-by-commit-message-td25288537.html])
* Several minor bug fixes

h3. 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 ([4270@issue])

h3. Version 1.6 (Aug 28, 2009)

* Fixed a bug in polling on slaves ([4299@issue])
* Fixed "authentication cancelled error" problem ([3936@issue])

h3. Version 1.5 (Aug 19, 2009)

* Polling is performed on the slaves now ([report|http://www.nabble.com/svn-connection-from-slave-only-td24970587.html])
* "Tag this Build" fails for 1.311\+ with SVN Plugin ([4018@issue])

h3. Version 1.3 (July 8, 2009)

* Subversion checkouts created files for symlinks ([3949@issue])

h3. Version 1.2 (June 24, 2009)

* Fixed "endless authentication to SVN when invalid user/password" issue ([2909@issue])

h3. Version 1.0 (June 15, 2009)

* Initial version split off from the core, to isolate SVNKit that has [a commercial-unfriendly license|http://svnkit.com/license.html].