Skip to content

Commit aaa7766

Browse files
committed
Refactor Jenkins pipeline
- Remove usage of parallel in the build and package stages - Retain usage of parallel in the deploy stages - Separate build and package into separate scripts to support build-only stages - Add a build-only stage for dev/feature branches
1 parent f11ca4e commit aaa7766

File tree

1 file changed

+38
-15
lines changed

1 file changed

+38
-15
lines changed

Jenkinsfile

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
- TODO: #527 Get this list automatically from python-ci.yml at runtime.
1111
*/
1212

13-
def indicator_list = ["backfill_corrections", "changehc", "claims_hosp", "google_symptoms", "hhs_hosp", "nchs_mortality", "quidel_covidtest", "sir_complainsalot", "doctor_visits", "nwss_wastewater", "nssp"]
13+
def indicator_list = ['backfill_corrections', 'changehc', 'claims_hosp', 'google_symptoms', 'hhs_hosp', 'nchs_mortality', 'quidel_covidtest', 'sir_complainsalot', 'doctor_visits', 'nwss_wastewater', 'nssp']
1414
def build_package_main = [:]
1515
def build_package_prod = [:]
1616
def deploy_staging = [:]
@@ -19,39 +19,62 @@ def deploy_production = [:]
1919
pipeline {
2020
agent any
2121
stages {
22-
stage('Build and Package main') {
22+
stage('Build dev/feature branch') {
23+
when {
24+
not {
25+
anyOf {
26+
branch 'main'
27+
branch 'prod'
28+
}
29+
}
30+
}
31+
steps {
32+
script {
33+
indicator_list.each { indicator ->
34+
stage("Build ${indicator}") {
35+
sh "jenkins/build-indicator.sh ${indicator}"
36+
}
37+
}
38+
}
39+
}
40+
}
41+
stage('Build and Package main branch') {
2342
when {
24-
branch "main";
43+
branch 'main'
2544
}
2645
steps {
2746
script {
2847
indicator_list.each { indicator ->
29-
build_package_main[indicator] = {
30-
sh "jenkins/build-and-package.sh ${indicator} main"
48+
stage("Build ${indicator}") {
49+
sh "jenkins/build-indicator.sh ${indicator}"
50+
}
51+
stage("Package ${indicator}") {
52+
sh "jenkins/package-indicator.sh ${indicator} main"
3153
}
3254
}
33-
parallel build_package_main
3455
}
3556
}
3657
}
37-
stage('Build and Package prod') {
58+
stage('Build and Package prod branch') {
3859
when {
39-
branch "prod";
60+
branch 'prod'
4061
}
4162
steps {
4263
script {
4364
indicator_list.each { indicator ->
44-
build_package_prod[indicator] = {
45-
sh "jenkins/build-and-package.sh ${indicator} prod"
65+
stage("Build ${indicator}") {
66+
sh "jenkins/build-indicator.sh ${indicator}"
67+
}
68+
stage("Package ${indicator}") {
69+
sh "jenkins/package-indicator.sh ${indicator} prod"
4670
}
4771
}
48-
parallel build_package_prod
4972
}
5073
}
5174
}
52-
stage('Deploy staging') {
75+
stage('Deploy main branch to staging env') {
5376
when {
54-
branch "main";
77+
branch 'main'
5578
}
5679
steps {
5780
script {
@@ -64,9 +87,9 @@ pipeline {
6487
}
6588
}
6689
}
67-
stage('Deploy production') {
90+
stage('Deploy prod branch to production env') {
6891
when {
69-
branch "prod";
92+
branch 'prod'
7093
}
7194
steps {
7295
script {

0 commit comments

Comments
 (0)