forked from java2kus/deploy_template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
73 lines (55 loc) · 1.61 KB
/
Jenkinsfile
File metadata and controls
73 lines (55 loc) · 1.61 KB
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
node() {
stage 'Setting up our environment'
// set the BUILD_VERSION based on the Jenkins BUILD_NUMBER
env.BUILD_VERSION = "v${env.BUILD_NUMBER}"
env.APP_NAME = ""
env.APP_ENV = "development"
env.BUILD_CONTAINER = ""
env.AWS_ACCOUNT_ID = ""
env.AWS_ACCOUNT_NAME = ""
env.AWS_PROFILE = ""
env.DOCKER_REPO = "${env.AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com"
env.BUILD_DIR = ""
env.IMAGE_NAME = ""
// set some stuff that needs to get passed in to the build container
env.DOCKER_ARGS = "-e BUILD_VERSION=${env.BUILD_VERSION} -e IMAGE_NAME=${env.IMAGE_NAME}"
sh 'env'
//----------
stage 'Checking for clean'
if (fileExists('Makefile')) {
echo 'Found Makefile, cleaning'
sh 'make docker-clean'
} else {
echo 'No Makefile, skipping clean'
}
//----------
stage 'Checking out source code'
checkout scm
//----------
stage 'Making deployment build'
sh 'make docker-release'
//----------
stage 'Pushing to ECR'
sh 'make aws-ecr-auth'
sh 'make aws-ecr-push'
//----------
stage 'Deploy app'
switch (env.BRANCH_NAME) {
case "staging":
env.APP_ENV = "staging"
sh 'make aws-ecs-task-create'
sh 'make aws-ecs-service-update'
sh 'make aws-ecs-service-status-poll'
sh 'make aws-ecs-service-stable'
break
case "master":
env.APP_ENV = "production"
sh 'make aws-ecs-task-create'
sh 'make aws-ecs-service-update'
sh 'make aws-ecs-service-status-poll'
sh 'make aws-ecs-service-stable'
break
default:
echo "Skipping deployment, branch ${env.BRANCH_NAME} not configured."
}
}