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

前端 未结 6 2212
逝去的感伤
逝去的感伤 2020-12-09 04:42

We have been using Jenkins for Continuous Integration for some time. A typical build job specifies the SVN repository and credentials in the \"Source Code Management\" secti

6条回答
  •  被撕碎了的回忆
    2020-12-09 04:45

    So, we had A LOT of problems getting this to work. Here is how we solved the problem:

    In Jenkins you make a Pipeline Job. The only contents that are required in this job are:

    • POLL SCM (with some arbitrary value such as @monthly)
    • Where the job should find your Jenkinsfile

    Every other setting goes into the Jenkinsfile. However:

      triggers {
    pollSCM('@monthly')}
    

    Should STILL be specified in your Jenkinsfile even though it is already specified in your job.

    However, as zionyx said you need to checkout before you do anything else. In our case we wanted to avoid this for many reasons. Luckily it still works if you have: depthOption: 'empty'.

    Finally, you need to manually start the first job run.

    We made a little function that you can perhaps use:

    def checkoutSVN(Boolean ignoreExternalsOption, String local, String remote, String updater) {
    checkout([$class: 'SubversionSCM', 
        additionalCredentials: 
        [[credentialsId: 'get-this-from-your-jenkins', 
        realm: ' CollabNet Subversion Repository']], 
        excludedCommitMessages: '', 
        excludedRegions: '', 
        excludedRevprop: '', 
        excludedUsers: '', 
        filterChangelog: false, 
        ignoreDirPropChanges: false, 
        includedRegions: '', 
        locations: [[credentialsId: 'get-this-from-your-jenkins', 
        depthOption: 'empty', 
        ignoreExternalsOption: ignoreExternalsOption, 
        local: local, 
        remote: remote]], 
        quietOperation: false,
        workspaceUpdater: [$class: updater]])}
    

提交回复
热议问题