forked from apache/airflow
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Jenkinsfile
85 lines (81 loc) · 3.78 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
pipeline {
agent { label "production" }
stages {
stage("BUILD") {
steps {
withAWS(profile:"JUMBO-ACCOUNT") {
script {
def branch = env.GIT_BRANCH.replaceAll("(.*)/", "")
def webserver_config
def airflow_cfg
def airflow_prometheus_exporter
if (branch == "zmaster") {
webserver_config = 'webserver_config-prod.py'
airflow_cfg = 'airflow-prod.cfg'
airflow_prometheus_exporter = 'git+https://github.com/ayush-san/airflow-prometheus-exporter.git@master'
} else if (branch == "zstaging") {
webserver_config = 'webserver_config-staging.py'
airflow_cfg = 'airflow-staging.cfg'
airflow_prometheus_exporter = 'git+https://github.com/ayush-san/airflow-prometheus-exporter.git@master'
} else {
webserver_config = 'webserver_config-dev.py'
airflow_cfg = 'airflow-dev.cfg'
airflow_prometheus_exporter = 'git+https://github.com/ayush-san/airflow-prometheus-exporter.git@master'
}
sh "docker build -t zdp-airflow:${branch} --build-arg WEBSERVER_CONFIG=${webserver_config} " +
"--build-arg AIRFLOW_CFG=${airflow_cfg} --build-arg " +
"ADDITIONAL_PYTHON_DEPS=${airflow_prometheus_exporter} ."
}
}
}
}
stage("ECR PUSH") {
steps {
withAWS(profile:"JUMBO-ACCOUNT") {
script {
def branch = env.GIT_BRANCH.replaceAll("(.*)/", "")
def tag = "${branch}_${GIT_COMMIT}"
image_tags = ["${branch}", "${tag}"]
sh "\$(aws ecr get-login --no-include-email --region ap-southeast-1)"
image_tags.each{ image_tag ->
sh "docker tag zdp-airflow:${branch} \
125719378300.dkr.ecr.ap-southeast-1.amazonaws.com/zdp-airflow:${image_tag}"
sh "docker push 125719378300.dkr.ecr.ap-southeast-1.amazonaws.com/zdp-airflow:${image_tag}"
}
}
}
}
}
// TODO: Update services/task-definitions after each deployment
/* stage("ECS UPDATE") {
steps {
withAWS(profile:"JUMBO-ACCOUNT") {
script {
def branch = env.GIT_BRANCH.replaceAll("(.*)/", "")
def services = ['apache-webserver','apache-scheduler','apache-flower','apache-worker']
def cluster
if (branch == "zmaster") {
cluster = "zdp-airflow"
} else if (branch == "zstaging") {
cluster = "zdp-staging-airflow"
} else {
cluster = "zdp-dev-airflow"
}
services.each { service ->
sh "aws ecs update-service --cluster ${cluster} --service ${service} --force-new-deployment"
}
}
}
}
} */
stage("CLEAN") {
steps {
withAWS(profile:"JUMBO-ACCOUNT") {
script {
sh "docker system prune -f"
}
}
}
}
}
}