0

I just spent a day wading through a decade's worth of SO questions, forum posts and the Jenkins Subversion Plugin wiki and documentation.

The question I was trying to answer:

  • What is the current minimal setup required to trigger jobs by Subversion commits?

Questions I couldn't answer:

  • What are pros / cons of using wget vs curl?
  • What is the effect of passing the REV parameter?

Working with Jenkins 2.164.3 and Subversion 1.9.7, each set up on it's own Ubuntu Server 18.04, and each behind it's own Apache HTTP Server with LetsEncrypt SSL certificates for HTTPS.

Reto Höhener
  • 5,419
  • 4
  • 39
  • 79

1 Answers1

0

This is the minimal svn post-commit hook that worked for me:

#!/bin/sh
REPO="$1"
REV="$2"
UUID="$(/usr/bin/svnlook uuid ${REPO})"
CHANGED="$(/usr/bin/svnlook changed -r ${REV} ${REPO})"    
SERVER_URL="https://<redacted>/jenkins"
USER="<redacted>"
API_TOKEN="<redacted>" # not the password

/usr/bin/curl -X POST -s -u "${USER}:${API_TOKEN}" -d "${CHANGED}" ${SERVER_URL}/subversion/${UUID}/notifyCommit

Notes:

  • CSRF is enabled, but USER:API_TOKEN seems to be enough (no need for crumbs).
  • Not specifying any Content-Type headers seems to be just fine
  • Not sending ?rev=${REV} seems to be just fine (what's the difference?)
  • Not necessary to configure special build trigger tokens (see screenshot)

Jenkins log output with (8,706) and without (-1) rev parameter:

May 15, 2019 8:04:28 PM INFO jenkins.scm.impl.subversion.SubversionSCMSource$ListenerImpl onNotify
Received post-commit hook from f9.... for revision [8,706 vs -1] on paths [project1/pom.xml, ...]
May 15, 2019 8:04:28 PM INFO jenkins.scm.impl.subversion.SubversionSCMSource$ListenerImpl onNotify
No subversion consumers for UUID f9....
May 15, 2019 8:04:28 PM INFO hudson.triggers.SCMTrigger$Runner run
SCM changes detected in project1. Triggering  #20

Job configuration:

enter image description here

Reto Höhener
  • 5,419
  • 4
  • 39
  • 79