-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.groovy
More file actions
91 lines (77 loc) · 2.12 KB
/
Copy pathplugin.groovy
File metadata and controls
91 lines (77 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env groovy
def createJob(String pluginName) {
def namespace = "scm-manager-plugins"
multibranchPipelineJob("SCM/${namespace}/${pluginName}") {
branchSources {
branchSource {
source {
scmManager {
id('ecosystem@scm-manager/' + pluginName)
credentialsId('SCM-Manager')
serverUrl('https://ecosystem.cloudogu.com/scm')
repository("${namespace}/${pluginName}/git")
traits {
scmManagerBranchDiscoveryTrait()
pullRequestDiscoveryTrait {
excludeBranchesWithPRs(true)
}
}
}
}
strategy {
}
}
}
orphanedItemStrategy {
discardOldItems {
numToKeep(5)
}
}
factory {
pipelineBranchDefaultsProjectFactory {
// The ID of the default Jenkinsfile to use from the global Config
// File Management.
scriptId('ScmPluginJenkinsfile')
// If enabled, the configured default Jenkinsfile will be run within
// a Groovy sandbox.
useSandbox false
}
}
}
queue("${namespace}/${pluginName}")
}
def createFolders() {
folder('SCM/scm-manager-plugins') {
description('SCM-Manager Plugins')
}
}
def createScmPluginJenkinsfile() {
configFiles {
groovyScript {
id('ScmPluginJenkinsfile')
name('Jenkinsfile')
comment('Jenkinsfile for SCM-Manager Plugins')
content(readFileFromWorkspace('templates/Jenkinsfile.default'))
}
}
}
def createJobs() {
def namespace = "scm-manager-plugins"
URL apiUrl = new URL("https://ecosystem.cloudogu.com/scm/api/v2/repositories/${namespace}?pageSize=1000")
def repositories = new groovy.json.JsonSlurper().parse(apiUrl)
repositories._embedded.repositories.each{ repo ->
createJob(repo.name)
}
}
def pluginName = jm.getParameters().pluginName
if ("none".equals(pluginName)) {
createScmPluginJenkinsfile()
} else if ("all".equals(pluginName)) {
createScmPluginJenkinsfile()
createFolders()
createJobs()
} else {
createScmPluginJenkinsfile()
createFolders()
createJob(pluginName)
}