How do I configure a Jenkins Pipeline to be triggered by polling SubVersion?

Using a Jenkins Declarative Pipeline script, you can configure a job to poll an SVN repository URL every 10 minutes as follows:

pipeline {
    agent any
    triggers {
        pollSCM 'H/10 * * * *'
    }
    stages {
        stage('checkout') {
            steps {
                checkout([
                    $class: 'SubversionSCM', 
                    additionalCredentials: [], 
                    excludedCommitMessages: '', 
                    excludedRegions: '', 
                    excludedRevprop: '', 
                    excludedUsers: '', 
                    filterChangelog: false, 
                    ignoreDirPropChanges: false, 
                    includedRegions: '', 
                    locations: [[
                        credentialsId: 'mySvnCredentials', 
                        depthOption: 'infinity',
                        ignoreExternalsOption: true, 
                        local: '.', 
                        remote: 'http://example.com/svn/url/trunk']], 
                    workspaceUpdater: [$class: 'CheckoutUpdater']
                ])
            }
        }
    }
}

The pollSCM trigger should automatically poll all SCM Repository URLs associated with your build, including URLs specified by checkout steps, the URL of your Declarative Pipeline script from SCM, and the URL of your Global Pipeline Libraries. If you truly want the pipeline to be run for every single revision however, you'll need to set up a post-commit hook instead.


The solution that I have found to work is:

  1. Move the pipeline script into a file (the default is JenkinsFile) and store this in the root of my project in SubVersion.
  2. Set my pipeline job definition source to "Pipeline script from SCM", enter the details of where to find my project in SubVersion as per a normal Jenkins build job, and set the Script Path to point at the JenkinsFile containing the pipeline script.
  3. Set the build trigger of the pipeline job to "Poll SCM" and enter a schedule.
  4. Manually run the pipeline job

It seemed to be step 4, manually running the pipeline job that caused the poll trigger to pick up the correct repository to poll. Before that it didn't seem to know where to look.