• Stars
    star
    126
  • Rank 274,406 (Top 6 %)
  • Language
    Java
  • Created over 13 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Jenkins subversion plugin

Jenkins Subversion Plugin

Jenkins Plugin GitHub release Jenkins Plugin Installs

This plugin adds the Subversion support (via SVNKit) to Jenkins.

Basic Usage

Once this plugin is installed, you'll see Subversion as one of the options in the SCM section of job configurations. 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

Proxy

You can set the proxy in C:/Users/<user>/AppData/Roaming/Subversion/servers (Windows) or ~/.subversion/servers (Linux)

(Jenkins as a service on Windows : C:\Windows\SysWOW64\config\systemprofile\AppData\Roaming\Subversion\servers)

There's a tension between doing this in Jenkins vs following the existing Subversion convention — the former has a benefit of being available on all the agents. In this case, the proxy is a system dependent setting, which might be different between different agents, so I think it makes sense to keep it in ~/.subversion/servers. (See https://issues.jenkins-ci.org/browse/JENKINS-4041)

Post-commit hook

Jenkins 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 Jenkins detects a change.

To reduce this delay, you can set up a post commit hook so the Subversion repository can notify Jenkins whenever a change is made to that repository. To do this, put the following script in your post-commit file (in the $REPOSITORY/hooks directory):

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://server/subversion/${UUID}/notifyCommit?rev=$REV

Notice the rev=$REV parameter, this tells Jenkins to check out exactly the revision which was reported by the hook. If your job has multiple Subversion module locations defined, this may lead to inconsistent checkouts - so it's recommended to leave out '?rev=$REV' in that case.
You may also want to leave out the '?rev=$REV' parameter if you are using Maven to release your projects and do not want Jenkins to build the intermediate prepare-release commit (ie: the released artifacts).
See JENKINS-14254 for details.

Jobs on Jenkins 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 (in the $REPOSITORY/hooks directory), 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 Jenkins has to allow anonymous read access (specifically, "Job > Read" access) to the system. If access control to your Jenkins is more restrictive, you may need to specify the username and password, depending on how your authentication is configured.

If your Jenkins 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/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/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)'`

Considerations

Since wget by default retries up to 20 times when not succeeding within the given timeout, --timeout=2 on a slow SVN server may cause Jenkins to scan the repository many more times than needed, further slowing down the SVN Server which after a while makes Jenkins unresponsive.

Possible solutions to this problem are to increase the timeout, to add a lower maximum number of retries using the argument --retries=3 or to make the wget call asynchronous (and thus ignoring any communication errors) by adding 2>&1 & last on the wget call.

Having the timeout too low can also cause your commits to hang and throw either 502 errors if you are behind a proxy, or post-commit errors if not. Increasing the timeout until you no longer see wget retrying should fix the issue.

More robust *nix post-commit hook example

The basic script above is fine if your server does not do authentication or you have no problem providing anonymous read access to Jenkins (as well as anonymous read to all the individual jobs you want to trigger if you are using project-based matrix authorization). Here is a script that includes the more robust security concepts hinted at in the basic example.

#!/bin/sh
REPOS="$1"
REV="$2"

# No environment is passed to svn hook scripts; set paths to external tools explicitly:
WGET=/usr/bin/wget
SVNLOOK=/usr/bin/svnlook

# If your server requires authentication, it is recommended that you set up a .netrc file to store your username and password
# Better yet, since Jenkins v. 1.426, use the generated API Token in place of the password
# See https://wiki.jenkins-ci.org/display/JENKINS/Authenticating+scripted+clients
# Since no environment is passed to hook scripts, you need to set $HOME (where your .netrc lives)
# By convention, this should be the home dir of whichever user is running the svn process (i.e. apache)
HOME=/var/www/

UUID=`$SVNLOOK uuid $REPOS`
NOTIFY_URL="subversion/${UUID}/notifyCommit?rev=${REV}"
CRUMB_ISSUER_URL='crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)'

function notifyCI {
    # URL to Jenkins server application (with protocol, hostname, port and deployment descriptor if needed)
    CISERVER=$1

    # Check if "[X] Prevent Cross Site Request Forgery exploits" is activated
    # so we can present a valid crumb or a proper header
    CONTENT_TYPE_HEADER="--header Content-Type:text/plain;charset=UTF-8"
    CRUMB=`$WGET --auth-no-challenge --output-document - ${CISERVER}/${CRUMB_ISSUER_URL}`
    if [ "$CRUMB" != "" ]; then CRUMB_HEADER="--header $CRUMB"; fi

    $WGET \
        --auth-no-challenge \
        $CONTENT_TYPE_HEADER \
        $CRUMB_HEADER \
        --post-data "`$SVNLOOK changed --revision $REV $REPOS`" \
        --output-document "-"\
        --timeout=2 \
        ${CISERVER}/${NOTIFY_URL}
}

# The code above was placed in a function so you can easily notify multiple Jenkins servers:
notifyCI "http://myPC.company.local:8080"
notifyCI "http://jenkins.company.com:8080/jenkins"

The script above takes care of the Prevent Cross Site Request Forgery exploits option if you have it enabled on your server. If you do not have that option enabled, the extra wget call is harmless, but feel free to remove it if you do not need it. The script above also requires that you set up a .netrc file in the home directory of the user you are running subversion as (either the svnserve process or httpd). For more info on .netrc file syntax, look here. The script above makes it easy to notify multiple Jenkins servers of the same SVN commit. If you have a .netrc file, it keeps it easy even if they have different admin users set up. If you don't want to mess with a .netrc file, you could just hard-code the user and password (or API Token) info in the file and add --username=user and --password="pass" flags to the wget calls.

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 (in the $REPOSITORY/hooks directory):

SET REPOS=%1
SET REV=%2
SET CSCRIPT=%windir%\system32\cscript.exe
SET VBSCRIPT=C:\Repositories\post-commit-hook-jenkins.vbs
SET SVNLOOK=C:\Subversion\svnlook.exe
SET JENKINS=http://server/
REM AUTHORIZATION: Set to "" for anonymous acceess
REM AUTHORIZATION: Set to encoded Base64 string, generated from "user_id:api_token" 
REM                found on Jenkins under "user/configure/API token"
REM                User needs "Job/Read" permission on Jenkins
SET AUTHORIZATION=""
"%CSCRIPT%" "%VBSCRIPT%" "%REPOS%" %2 "%SVNLOOK%" %JENKINS% %AUTHORIZATION%

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)
jenkins       = WScript.Arguments.Item(3)
authorization = WScript.Arguments.Item(4)

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 = jenkins + "crumbIssuer/api/xml?xpath=concat(//crumbRequestField,"":"",//crumb)"
Set http = CreateObject("Microsoft.XMLHTTP")
http.open "GET", url, False
http.setRequestHeader "Content-Type", "text/plain;charset=UTF-8"
if not authorization = "" then
  http.setRequestHeader "Authorization", "Basic " + authorization
end if
http.send
crumb = null
if http.status = 200 then
  crumb = split(http.responseText,":")
end if

url = jenkins + "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"
if not authorization = "" then
  http.setRequestHeader "Authorization", "Basic " + authorization
end if
if not isnull(crumb) then 
  http.setRequestHeader crumb(0),crumb(1)
end if
http.send changed
if http.status <> 200 then
  Wscript.Echo "Error. HTTP Status: " & http.status & ". Body: " & http.responseText
end if

Perform Polling from the Controller

JIRA JENKINS-5413 documents problems with running the SCM polling trigger on agents. Version 1.21 of the Subversion plugin can perform the polling on the Jenkins controller if the hudson.scm.SubversionSCM.pollFromMaster system property is set to true.

Subversion Revision and URL information as Environment Variables

The Subversion SCM plugin exports the svn revisions and URLs of the build's subversion modules as environment variables. These are $SVN_REVISION_n and $SVN_URL_n, where n is the 1-based index of the module in the configuration.

For backwards compatibility if there's only a single module, its values are also exported as $SVN_REVISION and $SVN_URL.

Note that the revision number exposed is the 'last-changed' revision number of the particular directory and not the current revision of the repository. (See What are these two revision numbers in svn info?)

Kerberos authentication

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

TroubleShooting

Someone suggested in the Jenkins IRC channel that if you are getting an error and a long svnkit stack trace that looks like:

 ERROR: svn: authentication cancelled

org.tmatesoft.svn.core.SVNCancelException: svn: authentication cancelled

Then,

You could try to enable verbose log over the plugin an SVNKit library, to do that add a logger to those loggers with log level ALL , it is really verbose so just after configure it make the test and change the log level again to ERROR or INFO.

  • svnkit
  • svnkit-network
  • svnkit-wc
  • hudson.scm.SubversionSCM

{.confluence-embedded-image height="250"}

lightweight checkout capability for Subversion on Multibranch Pipeline projects and Externals support

Lightweight checkout capability for Subversion on Multibranch Pipeline projects does not support externals, so in order to use Subversion plugin in a Multibranch Pipeline project with a repository with externals, you should disable the lightweight checkout capability by setting the property `-Djenkins.scm.impl.subversion.SubversionSCMFileSystem.disable=<true/false>`

Change Log

Version 2.12.2 and newer

See GitHub releases.

Older

See the old changelog.

Trademarks

Apache, Apache Subversion and Subversion are trademarks of the Apache Software Foundation

More Repositories

1

jenkins

Jenkins automation server
Java
21,381
star
2

docker

Docker official jenkins repo
Dockerfile
6,144
star
3

pipeline-examples

A collection of examples, tips and tricks and snippets of scripting for the Jenkins Pipeline plugin
Groovy
4,117
star
4

blueocean-plugin

Blue Ocean is a reboot of the Jenkins CI/CD User Experience
Java
2,872
star
5

configuration-as-code-plugin

Jenkins Configuration as Code Plugin
Java
2,521
star
6

kubernetes-plugin

Jenkins plugin to run dynamic agents in a Kubernetes/Docker environment
Java
2,206
star
7

job-dsl-plugin

A Groovy DSL for Jenkins Jobs - Sweeeeet!
Groovy
1,851
star
8

pipeline-plugin

Obsolete home for Pipeline plugins
1,711
star
9

JenkinsPipelineUnit

Framework for unit testing Jenkins pipelines
Groovy
1,426
star
10

gitlab-plugin

A Jenkins plugin for interfacing with GitLab
Java
1,418
star
11

jenkinsfile-runner

A command line tool to run Jenkinsfile as a function
Java
1,114
star
12

java-client-api

A Jenkins API client for Java
Java
888
star
13

jenkins-scripts

Scripts in Groovy, shell, Ruby, Python, whatever for managing/interacting with Jenkins
Groovy
880
star
14

build-monitor-plugin

Jenkins Build Monitor Plugin
Java
722
star
15

slack-plugin

A Jenkins plugin for posting notifications to a Slack channel
Java
664
star
16

git-plugin

Git repository access for Jenkins jobs
Java
660
star
17

pipeline-model-definition-plugin

Groovy
557
star
18

ghprb-plugin

github pull requests builder plugin for Jenkins
Java
495
star
19

docker-workflow-plugin

Jenkins plugin which allows building, testing, and using Docker images from Jenkins Pipeline projects.
Java
492
star
20

docker-plugin

Jenkins Cloud Plugin that uses Docker
Java
482
star
21

docker-inbound-agent

Docker image for a Jenkins agent which can connect to Jenkins using TCP or Websocket protocols
PowerShell
466
star
22

helm-charts

Jenkins helm charts
Mustache
448
star
23

pipeline-aws-plugin

Jenkins Pipeline Step Plugin for AWS
Java
423
star
24

jenkins.rb

Deprecated, see https://www.jenkins.io/jep/7
Ruby
394
star
25

generic-webhook-trigger-plugin

Can receive any HTTP request, extract any values from JSON or XML and trigger a job with those values available as variables. Works with GitHub, GitLab, Bitbucket, Jira and many more.
Java
377
star
26

email-ext-plugin

Jenkins Email Extension Plugin
Java
338
star
27

dingtalk-plugin

Dingtalk for jenkins
Java
336
star
28

warnings-ng-plugin

Jenkins Warnings Plugin - Next Generation
Java
323
star
29

plugin-installation-manager-tool

Plugin Manager CLI tool for Jenkins
Java
301
star
30

mesos-plugin

Mesos Cloud Jenkins Plugin
Java
291
star
31

github-plugin

Jenkins GitHub plugin
Java
286
star
32

ec2-plugin

Jenkins ec2 plugin
Java
282
star
33

ssh-steps-plugin

Jenkins pipeline steps which provides SSH facilities such as command execution or file transfer for continuous delivery.
Java
273
star
34

ansicolor-plugin

Jenkins ANSI Color Plugin
Java
253
star
35

pipeline-utility-steps-plugin

Small, miscellaneous, cross platform utility steps for Jenkins Pipeline jobs.
Java
237
star
36

docker-agent

Base Docker image for Jenkins Agents
PowerShell
231
star
37

ansible-plugin

Jenkins Ansible plugin
Java
223
star
38

workflow-cps-global-lib-plugin

Java
223
star
39

lib-file-leak-detector

Java agent that detects file handle leak
Java
217
star
40

hashicorp-vault-plugin

Jenkins plugin to populate environment variables from secrets stored in HashiCorp's Vault.
Java
214
star
41

bitbucket-branch-source-plugin

Bitbucket Branch Source Plugin
Java
213
star
42

remoting

Jenkins Remoting module
Java
212
star
43

workflow-aggregator-plugin

211
star
44

gerrit-trigger-plugin

Java
209
star
45

android-emulator-plugin

Android Emulator plugin for Jenkins
Java
207
star
46

docker-slaves-plugin

A Jenkins plugin to run builds inside Docker containers
Java
205
star
47

pipeline-stage-view-plugin

Visualizes Jenkins pipelines
JavaScript
204
star
48

jenkinsfile-runner-github-actions

Jenkins single-shot pipeline execution in a GitHub Action POC
Shell
199
star
49

github-branch-source-plugin

GitHub Branch Source Plugin
Java
193
star
50

amazon-ecs-plugin

Amazon EC2 Container Service Plugin for Jenkins
Java
193
star
51

trilead-ssh2

Patched trilead-ssh2 used in Jenkins
Java
193
star
52

cucumber-reports-plugin

Jenkins plugin to generate cucumber-jvm reports
Java
192
star
53

docker-build-publish-plugin

Java
192
star
54

performance-plugin

Performance Test Running and Reporting for Jenkins CI
Java
188
star
55

jira-plugin

Jenkins jira plugin
Java
168
star
56

gitea-plugin

This plugin provides the Jenkins integration for Gitea.
Java
168
star
57

embeddable-build-status-plugin

Embed build status of Jenkins jobs in web pages
Java
167
star
58

stashnotifier-plugin

A Jenkins Plugin to notify Atlassian Stash|Bitbucket of build results
Java
166
star
59

docker-ssh-agent

Docker image for Jenkins agents connected over SSH
PowerShell
162
star
60

workflow-cps-plugin

Java
160
star
61

http-request-plugin

This plugin does a request to an url with some parameters.
Java
154
star
62

stapler

Stapler web framework
Java
154
star
63

kubernetes-pipeline-plugin

Kubernetes Pipeline is Jenkins plugin which extends Jenkins Pipeline to provide native support for using Kubernetes pods, secrets and volumes to perform builds
Java
154
star
64

tfs-plugin

Jenkins tfs plugin
Java
145
star
65

jep

Jenkins Enhancement Proposals
Shell
144
star
66

kubernetes-cd-plugin

A Jenkins plugin to deploy to Kubernetes cluster
Java
140
star
67

jacoco-plugin

Jenkins JaCoCo Plugin
Java
139
star
68

qy-wechat-notification-plugin

企业微信Jenkins构建通知插件
Java
138
star
69

swarm-plugin

Jenkins swarm plugin
Java
133
star
70

git-client-plugin

Git client API for Jenkins plugins
Java
130
star
71

dependency-check-plugin

Jenkins plugin for OWASP Dependency-Check. Inspects project components for known vulnerabilities (e.g. CVEs).
Java
125
star
72

role-strategy-plugin

Jenkins Role-Strategy plugin
Java
120
star
73

groovy-sandbox

(Deprecated) Compile-time transformer to run Groovy code in a restrictive sandbox
Java
120
star
74

jenkins-design-language

Styles, assets, and React classes for Jenkins Design Language
TypeScript
116
star
75

acceptance-test-harness

Acceptance tests cases for Jenkins and its plugins based on selenium and docker.
Java
116
star
76

scm-sync-configuration-plugin

Jenkins scm-sync-configuration plugin
Java
116
star
77

gitlab-branch-source-plugin

A Jenkins Plugin for GitLab Multibranch Pipeline jobs and Folder Organization
Java
115
star
78

git-parameter-plugin

Jenkins plugin for chosing Revision / Tag before build
Java
115
star
79

publish-over-ssh-plugin

Java
114
star
80

pipeline-as-yaml-plugin

Jenkins Pipeline As Yaml Plugin
Java
114
star
81

selenium-plugin

Jenkins selenium plugin
Java
112
star
82

docker-build-step-plugin

Java
111
star
83

code-coverage-api-plugin

Deprecated Jenkins Code Coverage Plugin
Java
111
star
84

jira-trigger-plugin

Triggers a build when a certain condition is matched in JIRA
Groovy
111
star
85

cobertura-plugin

Jenkins cobertura plugin
Java
110
star
86

gradle-plugin

Jenkins gradle plugin
Java
109
star
87

credentials-plugin

Provides Jenkins with extension points to securely store, manage, and bind credentials data to other Jenkins plugins, builds, pipelines, etc.
Java
107
star
88

jira-steps-plugin

Jenkins pipeline steps for integration with JIRA.
Java
104
star
89

artifactory-plugin

Jenkins artifactory plugin
Java
104
star
90

build-flow-plugin

A plugin to manage job orchestration
Groovy
103
star
91

throttle-concurrent-builds-plugin

Java
101
star
92

github-oauth-plugin

Jenkins authentication plugin using GitHub OAuth as the source.
Java
99
star
93

pipeline-graph-view-plugin

Java
99
star
94

promoted-builds-plugin

Jenkins Promoted Builds Plugin
Java
96
star
95

ssh-slaves-plugin

SSH Build Agents Plugin for Jenkins
Java
96
star
96

github-pr-coverage-status-plugin

Nice test coverage icon for your pull requests just from Jenkins
Java
93
star
97

jenkins-test-harness

Unit test framework for Jenkins core and its plugins
Java
92
star
98

opentelemetry-plugin

Monitor and observe Jenkins with OpenTelemetry.
Java
90
star
99

localization-zh-cn-plugin

Chinese Localization for Jenkins
HTML
89
star
100

workflow-remote-loader-plugin

Load Pipeline scripts from remote locations (e.g. Git) - replaced by Pipeline: Groovy Libraries plugin
Java
88
star