-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gocd.groovy
100 lines (93 loc) · 2.86 KB
/
build.gocd.groovy
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
91
92
93
94
95
96
97
98
99
100
import cd.go.contrib.plugins.configrepo.groovy.dsl.GoCD
import cd.go.contrib.plugins.configrepo.groovy.dsl.Job
def javaTestJobs = { repo ->
return [
new Job("test", {
elasticProfileId = repo['elasticProfileForTests']
tasks {
bash {
commandString = './gradlew assemble check'
}
}
})
]
}
def defaultElasticProfile = 'ecs-gocd-dev-build'
def allRepos = [
[ 'org': 'gocd-contrib', repo: 'gocd-groovy-dsl-config-plugin', elasticProfileForTests: 'ecs-gocd-dev-build', testJobs: javaTestJobs, mainBranch: 'master' ],
]
def releaseCredentials = {
return [
GITHUB_TOKEN: 'AES:9Z9Lv85kry1oWWlOaCUF/w==:fWti8kD99VN7f++r7PfgLmXulS8GPmyb8bWm7yl1DYoDh1QihWEumO1mCfwiJ/O0',
]
}
GoCD.script {
pipelines {
allRepos.each { repo ->
pipeline("${repo['org']}-${repo['repo']}-pr") {
environmentVariables = repo['envVars']
materials {
githubPR("${repo['repo']}-material") {
url = "https://git.gocd.io/git/${repo['org']}/${repo['repo']}"
branch = "${repo['mainBranch']}"
}
}
group = "gocd" == repo['org'] ? "supported-plugins-pr" : "plugins-pr"
stages {
stage("test") {
jobs {
addAll(repo['testJobs'](repo))
}
}
}
}
pipeline("${repo['org']}-${repo['repo']}") {
environmentVariables = repo['envVars']
materials {
git {
url = "https://git.gocd.io/git/${repo['org']}/${repo['repo']}"
shallowClone = false
branch = repo['mainBranch']
}
}
group = "gocd" == repo['org'] ? "supported-plugins" : "plugins"
stages {
stage("test") {
jobs {
addAll(repo['testJobs'](repo))
}
}
stage("github-preview-release") {
environmentVariables = [GITHUB_USER: repo['org']]
secureEnvironmentVariables = releaseCredentials()
jobs {
job("create-preview-release") {
elasticProfileId = defaultElasticProfile
tasks {
bash {
commandString = './gradlew githubRelease'
}
}
}
}
}
stage("github-release") {
approval { type = 'manual' }
environmentVariables = [GITHUB_USER: repo['org'], PRERELEASE: "NO"]
secureEnvironmentVariables = releaseCredentials()
jobs {
job("create-release") {
elasticProfileId = defaultElasticProfile
tasks {
bash {
commandString = './gradlew githubRelease'
}
}
}
}
}
}
}
}
}
}