-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
59 lines (56 loc) · 1.21 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
pipeline {
agent any
stages {
stage('AWS Login') {
steps {
script {
sh("$(aws ecr get-login --no-include-email --region=eu-west-1)")
}
}
}
stage('Build and push docker images') {
steps {
script {
docker.build('nginx', '-f ./provision/nginx/Dockerfile .')
docker.withRegistry(ECR_REPO)
{
docker.image('nginx').push('latest')
}
docker.build('node', '-f ./provision/node/Dockerfile .')
docker.withRegistry(ECR_REPO)
{
docker.image('node').push('latest')
}
}
}
}
stage('Cluster up') {
steps {
script {
sh '''APP="lbv"
CLUSTER="${APP}-cluster"
SERVICE="${APP}-service"
LB="${APP}-elb"
IMAGE="nginx"
ecs-cli compose \\
--file ./docker-compose.prod.yml \\
--project-name ${SERVICE} \\
--cluster ${CLUSTER} \\
--verbose service up \\
--container-name ${IMAGE} \\
--container-port 80 \\
--load-balancer-name ${LB} \\
--deployment-min-healthy-percent 0 \\
--timeout 10
'''
}
}
}
}
environment {
ECR_REPO = credentials('ecr-repo')
}
options {
buildDiscarder(logRotator(numToKeepStr: '3'))
}
}