-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathjob-dsl-example.groovy
105 lines (103 loc) · 2.82 KB
/
job-dsl-example.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
101
102
103
104
105
def repository = 'codecentric/spring-samples'
def contentApi = new URL("https://api.github.com/repos/${repository}/contents")
def projects = new groovy.json.JsonSlurper().parse(contentApi.newReader())
projects.each {
def projectName = it.name
job(type: Maven) {
name("${projectName}")
triggers { scm("*/5 * * * *") }
scm {
git {
remote {
url("https://github.com/codecentric/spring-samples")
}
createTag(false)
}
}
rootPOM("${projectName}/pom.xml")
goals("clean package")
wrappers {
preBuildCleanup()
release {
preBuildSteps {
maven {
mavenInstallation("Maven 3.0.4")
rootPOM("${projectName}/pom.xml")
goals("build-helper:parse-version")
goals("versions:set")
property("newVersion", "\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.incrementalVersion}-\${BUILD_NUMBER}")
}
}
postSuccessfulBuildSteps {
maven {
rootPOM("${projectName}/pom.xml")
goals("deploy")
}
maven {
goals("scm:tag")
}
downstreamParameterized {
trigger("deploy-application") {
predefinedProp("STAGE", "development")
}
}
}
}
}
publishers {
groovyPostBuild("manager.addShortText(manager.build.getEnvironment(manager.listener)[\'POM_VERSION\'])")
}
promotions {
promotion("Development") {
icon("star-red")
conditions {
manual('')
}
actions {
downstreamParameterized {
trigger("deploy-application","SUCCESS",false,["buildStepFailure": "FAILURE","failure":"FAILURE","unstable":"UNSTABLE"]) {
predefinedProp("ENVIRONMENT","test-server")
predefinedProp("APPLICATION_NAME", "\${PROMOTED_JOB_FULL_NAME}")
predefinedProp("BUILD_ID","\${PROMOTED_NUMBER}")
}
}
}
}
promotion("QA") {
icon("star-yellow")
conditions {
manual('')
upstream("Development")
}
actions {
downstreamParameterized {
trigger("deploy-application","SUCCESS",false,["buildStepFailure": "FAILURE","failure":"FAILURE","unstable":"UNSTABLE"]) {
predefinedProp("ENVIRONMENT","qa-server")
predefinedProp("APPLICATION_NAME", "\${PROMOTED_JOB_FULL_NAME}")
predefinedProp("BUILD_ID","\${PROMOTED_NUMBER}")
}
}
}
}
promotion("Production") {
icon("star-green")
conditions {
manual('')
upstream("QA")
}
actions {
downstreamParameterized {
trigger("deploy-application","SUCCESS",false,["buildStepFailure": "FAILURE","failure":"FAILURE","unstable":"UNSTABLE"]) {
predefinedProp("ENVIRONMENT","prod-server")
predefinedProp("APPLICATION_NAME", "\${PROMOTED_JOB_FULL_NAME}")
predefinedProp("BUILD_ID","\${PROMOTED_NUMBER}")
}
}
}
}
}
}
}
job{
name("deploy-application")
}