multibranchPipelineJob('JobDSL Test Job 1') {
branchSources {
branchSource {
source {
git {
id('dummy')
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