wipeout repository & force clone for multibranch pipeline project

270 views
Skip to first unread message

Gil Shinar [EXT]

unread,
Nov 29, 2020, 8:59:00 AM11/29/20
to job-dsl-plugin
Hi,

Is there an option to add "wipe out repository & force clone" extention to jobs of type multibranch pipeline?
I couldn't find in the documentation and whatever I've tried didn't work

Thanks
Gil

Gil Shinar [EXT]

unread,
Dec 14, 2020, 3:21:54 AM12/14/20
to job-dsl-plugin
Can anyone please assist?

Warren Humphreys

unread,
Dec 14, 2020, 7:32:18 AM12/14/20
to job-dsl...@googlegroups.com
I solved this by using the wipeWorkspaceTrait as follows: -


multibranchPipelineJob('JobDSL Test Job 1') {
  branchSources {
    branchSource {
      source {
        git {
          id('dummy')
          remote('g...@bitbucket.org:example/jobdsl-test.git’)
          credentialsId('bitbucket')
          traits {

// ADD THIS
            wipeWorkspaceTrait()
//          ^^^^^^^^^^^^^^^^^^^^

            headWildcardFilter {
              includes('develop master PR-*')
              excludes('')
            }
          }
        }
      }
    }
  }
  description('JobDSL Test Job 1')
  configure {
    def traits = it / sources / data / 'jenkins.branch.BranchSource' / source / traits
    traits << 'jenkins.plugins.git.traits.BranchDiscoveryTrait'()
  }
}


This is just a snippet - it’s not the full job definition (which includes a strategy section etc), but should give you an idea.

Hope that helps (I know it took me a while to figure out too!)

Woz





--
You received this message because you are subscribed to the Google Groups "job-dsl-plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to job-dsl-plugi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/7ba72af8-2b47-4e82-a370-5d17b9e02f09n%40googlegroups.com.

Gil Shinar [EXT]

unread,
Dec 14, 2020, 9:25:31 AM12/14/20
to job-dsl-plugin
First thanks a lot!

What I'm still not sure is do I have to have the strategy section for the wipeWorkspaceTrait to work?

Gil Shinar [EXT]

unread,
Dec 14, 2020, 9:28:37 AM12/14/20
to job-dsl-plugin
One more question, why isn't it in the 1.77 documentation?

Thanks
Gil

Gil Shinar [EXT]

unread,
Dec 21, 2020, 2:19:33 AM12/21/20
to job-dsl-plugin
Hi,

Can you please assist? BTW, I have opened the following ticket: https://issues.jenkins.io/browse/JENKINS-64349
In case it is not relevant and what you've suggested will work in version 1.77, you can close this ticket

Thanks
Gil

Gil Shinar [EXT]

unread,
Dec 21, 2020, 8:18:34 AM12/21/20
to job-dsl-plugin
Tried that and seems like it is working

Thanks
Gil

Reply all
Reply to author
Forward
0 new messages