-
Notifications
You must be signed in to change notification settings - Fork 17
/
Jenkinsfile
118 lines (114 loc) · 3.66 KB
/
Jenkinsfile
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
106
107
108
109
110
111
112
113
114
115
116
117
118
#!groovy
// Import shared lib.
@Library('jenkins-shared-library') _
/*
Declare variables.
- indicator_list should contain all the indicators to handle in the pipeline.
- Keep in sync with '.github/workflows/python-ci.yml'.
- TODO: #527 Get this list automatically from python-ci.yml at runtime.
*/
def indicator_list = ['backfill_corrections', 'changehc', 'claims_hosp', 'google_symptoms', 'hhs_hosp', 'nchs_mortality', 'quidel_covidtest', 'sir_complainsalot', 'doctor_visits', 'nwss_wastewater', 'nssp', 'nhsn']
def build_package_main = [:]
def build_package_prod = [:]
def deploy_staging = [:]
def deploy_production = [:]
pipeline {
agent any
environment {
// Set the PATH variable to include the pyenv shims directory.
PATH = "/var/lib/jenkins/.pyenv/shims:${env.PATH}"
}
stages {
stage('Build dev/feature branch') {
when {
not {
anyOf {
branch 'main'
branch 'prod'
}
}
}
steps {
script {
indicator_list.each { indicator ->
stage("Build ${indicator}") {
sh "jenkins/build-indicator.sh ${indicator}"
}
}
}
}
}
stage('Build and Package main branch') {
when {
branch 'main'
}
steps {
script {
indicator_list.each { indicator ->
stage("Build ${indicator}") {
sh "jenkins/build-indicator.sh ${indicator}"
}
stage("Package ${indicator}") {
sh "jenkins/package-indicator.sh ${indicator} main"
}
}
}
}
}
stage('Build and Package prod branch') {
when {
branch 'prod'
}
steps {
script {
indicator_list.each { indicator ->
stage("Build ${indicator}") {
sh "jenkins/build-indicator.sh ${indicator}"
}
stage("Package ${indicator}") {
sh "jenkins/package-indicator.sh ${indicator} prod"
}
}
}
}
}
stage('Deploy main branch to staging env') {
when {
branch 'main'
}
steps {
script {
indicator_list.each { indicator ->
deploy_staging[indicator] = {
sh "jenkins/deploy-staging.sh ${indicator}"
}
}
parallel deploy_staging
}
}
}
stage('Deploy prod branch to production env') {
when {
branch 'prod'
}
steps {
script {
indicator_list.each { indicator ->
deploy_production[indicator] = {
sh "jenkins/deploy-production.sh ${indicator}"
}
}
parallel deploy_production
}
}
}
}
post {
always {
script {
// Use slackNotifier.groovy from shared lib.
slackNotifier(currentBuild.currentResult)
}
}
}
}