1 |
def repository = 'codecentric/spring-samples' |
2 |
def contentApi = new URL("https://api.github.com/repos/${repository}/contents") |
3 |
def projects = new groovy.json.JsonSlurper().parse(contentApi.newReader()) |
4 |
projects.each { |
5 |
def projectName = it.name |
6 |
job(type: Maven) { |
7 |
name("${projectName}") |
8 |
triggers { scm("*/5 * * * *") } |
9 |
scm { |
10 |
git { |
11 |
remote { |
12 |
url("https://github.com/codecentric/spring-samples") |
13 |
} |
14 |
createTag(false) |
15 |
} |
16 |
} |
17 |
rootPOM("${projectName}/pom.xml") |
18 |
goals("clean package") |
19 |
wrappers { |
20 |
preBuildCleanup() |
21 |
release { |
22 |
preBuildSteps { |
23 |
maven { |
24 |
mavenInstallation("Maven 3.0.4") |
25 |
rootPOM("${projectName}/pom.xml") |
26 |
goals("build-helper:parse-version") |
27 |
goals("versions:set") |
28 |
property("newVersion", "\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.incrementalVersion}-\${BUILD_NUMBER}") |
29 |
} |
30 |
} |
31 |
postSuccessfulBuildSteps { |
32 |
maven { |
33 |
rootPOM("${projectName}/pom.xml") |
34 |
goals("deploy") |
35 |
} |
36 |
maven { |
37 |
goals("scm:tag") |
38 |
} |
39 |
downstreamParameterized { |
40 |
trigger("deploy-application") { |
41 |
predefinedProp("STAGE", "development") |
42 |
} |
43 |
} |
44 |
} |
45 |
} |
46 |
} |
47 |
publishers { |
48 |
groovyPostBuild("manager.addShortText(manager.build.getEnvironment(manager.listener)[\'POM_VERSION\'])") |
49 |
} |
50 |
promotions { |
51 |
promotion("Development") { |
52 |
icon("star-red") |
53 |
conditions { |
54 |
manual('') |
55 |
} |
56 |
actions { |
57 |
downstreamParameterized { |
58 |
trigger("deploy-application","SUCCESS",false,["buildStepFailure": "FAILURE","failure":"FAILURE","unstable":"UNSTABLE"]) { |
59 |
predefinedProp("ENVIRONMENT","test-server") |
60 |
predefinedProp("APPLICATION_NAME", "\${PROMOTED_JOB_FULL_NAME}") |
61 |
predefinedProp("BUILD_ID","\${PROMOTED_NUMBER}") |
62 |
} |
63 |
} |
64 |
} |
65 |
} |
66 |
promotion("QA") { |
67 |
icon("star-yellow") |
68 |
conditions { |
69 |
manual('') |
70 |
upstream("Development") |
71 |
} |
72 |
actions { |
73 |
downstreamParameterized { |
74 |
trigger("deploy-application","SUCCESS",false,["buildStepFailure": "FAILURE","failure":"FAILURE","unstable":"UNSTABLE"]) { |
75 |
predefinedProp("ENVIRONMENT","qa-server") |
76 |
predefinedProp("APPLICATION_NAME", "\${PROMOTED_JOB_FULL_NAME}") |
77 |
predefinedProp("BUILD_ID","\${PROMOTED_NUMBER}") |
78 |
} |
79 |
} |
80 |
} |
81 |
} |
82 |
promotion("Production") { |
83 |
icon("star-green") |
84 |
conditions { |
85 |
manual('') |
86 |
upstream("QA") |
87 |
} |
88 |
actions { |
89 |
downstreamParameterized { |
90 |
trigger("deploy-application","SUCCESS",false,["buildStepFailure": "FAILURE","failure":"FAILURE","unstable":"UNSTABLE"]) { |
91 |
predefinedProp("ENVIRONMENT","prod-server") |
92 |
predefinedProp("APPLICATION_NAME", "\${PROMOTED_JOB_FULL_NAME}") |
93 |
predefinedProp("BUILD_ID","\${PROMOTED_NUMBER}") |
94 |
} |
95 |
} |
96 |
} |
97 |
} |
98 |
} |
99 |
} |
100 |
} |
101 |
|
102 |
|
103 |
job{ |
104 |
name("deploy-application") |
105 |
} |