Takeover for application » master by source #1 from source that no longer exists
Branch reopened: master (ae0617dc2ceea28577b4c73356f705f2d597ae6c)
import org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject
import hudson.plugins.git.browser.GitWeb
import hudson.plugins.git.extensions.impl.CloneOption
import jenkins.branch.BranchSource
import jenkins.branch.DefaultBranchPropertyStrategy
import jenkins.plugins.git.GitSCMSource
import jenkins.plugins.git.traits.BranchDiscoveryTrait
import jenkins.plugins.git.traits.CloneOptionTrait
import jenkins.plugins.git.traits.TagDiscoveryTrait
def jenkinsInstance = jenkins.model.Jenkins.getInstance()
jenkinsInstance.getView("projects").getItems().each { project ->
if (project instanceof WorkflowMultiBranchProject) {
def sources = project.getSourcesList()
sources.clear()
def projectName = project.getName()
def REMOTE = "ssh://g...@git.company.com/projects/"+ projectName +".git"
GitSCMSource gitSCMSource = new GitSCMSource(null, REMOTE, "c9atdnbtdy1883", "*", "", false)
DefaultBranchPropertyStrategy strategy = new DefaultBranchPropertyStrategy(null)
def url = "http://git.company.com/gitweb/?p=projects/"+projectName+".git"
def browser = new GitWeb(url)
gitSCMSource.setBrowser(browser)
def traits = new ArrayList()
def branchTrait = new BranchDiscoveryTrait()
traits.add(branchTrait)
def tagTrait = new TagDiscoveryTrait()
traits.add(tagTrait)
def cloneOption = new CloneOption(false, false, "", null)
cloneOption.setDepth(0)
def cloneOptionTrait = new CloneOptionTrait(cloneOption)
traits.add(cloneOptionTrait)
gitSCMSource.setTraits(traits)
BranchSource branchSource = new BranchSource(gitSCMSource, strategy)
sources.add(branchSource)
}
}