Federico Bonelli
Federico Bonelli

Reputation: 849

Duplicate changelogs in jenkins pipeline script with SVN

This question is basically the same as this one except I'm using subversion, and no plugin update has done the trick for me.

I'm loading my Jenkinsfile script with a multibranch pipeline setting, and the changelog gets duplicated at each new checkout scm.

Since in my build I'm using multiple workspaces, allocated through node inside parallel blocks, I'm calling fresh checkouts for each of them, and the changelog duplication is getting a bit annoying.

Upvotes: 7

Views: 3035

Answers (3)

Deepu Sudhakar
Deepu Sudhakar

Reputation: 71

Rather than redefining the SCM class, one can still refer to the original "scm" object and disable the changelog like so:

checkout(changelog: false, scm: scm)

This will retain the intended behviour of "checkout scm" while disabling the changelog generation.

Upvotes: 7

Federico Bonelli
Federico Bonelli

Reputation: 849

Ben Herfurth's answer is good, I'll just post my final adaptation for it because I tried to wrap it up a bit in a single working function.

This function works for me as I have only one SVN repository to checkout, and everything else (e.g. passwords) have been configured already:

def checkout(){
    def svnLocation = scm.locations[0]
    checkout(changelog: false, scm: [$class: 'SubversionSCM', locations: [svnLocation], workspaceUpdater: [$class: 'UpdateWithCleanUpdater']])  
}

I just drop a call to this everywhere I need a fresh working copy.

node('linux') {        
   checkout()
   // ... run ITs on linux ...
}

node('windows') {
   checkout() // doesn't duplicate changelog anymore
   // ... run ITs on windows ....
}

Hope this helps others.

Upvotes: 3

Benjen
Benjen

Reputation: 133

Facing the same problem.

I am doing the following, until a fix for the SVN plug-in is released.

currentBuild.getChangeSets().clear()
checkout scm

Attention: you might have to approve the script calls via the "In-process Script approval" page.

This will clear the changelog from the Jenkins Job. The changelog will be filled again by the 'checkout scm' call. UPDATE: Check my edit below. This "solution" does not work, because adds back the removed revisions after a restart ... i don't get why, but ...

EDIT:

OK now I found a new way:

for(i = 0; i < scm.getLocations().length; i++) {
        def location = scm.getLocations()[i]
        def svn_url = location.remote
        checkout changelog: false, poll: false, scm: [$class: 'SubversionSCM', additionalCredentials: [], excludedCommitMessages: '', excludedRegions: '', excludedRevprop: '', excludedUsers: '', filterChangelog: false, ignoreDirPropChanges: false, includedRegions: '', locations: [[credentialsId: '252ad9ab-2f39-46f5-a77a-6196d1679dee', depthOption: 'infinity', ignoreExternalsOption: true, local: '.', remote: svn_url]], workspaceUpdater: [$class: 'UpdateWithRevertUpdater']]
    }

You should use the "Pipeline Syntax" page to get the credentials right. i tried using just

checkout changelog: false, scm

but that didn't work. So you have to use the long version shown above.

Upvotes: 6

Related Questions