-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
52 lines (44 loc) · 1.6 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
pipeline{
agent any
environment {
API_TAG = "api-${BUILD_NUMBER}"
WEB_TAG = "web-${BUILD_NUMBER}"
API_IMAGE = "${params.ECRURL}/nodeapprepo:$API_TAG"
WEB_IMAGE = "${params.ECRURL}/nodeapprepo:$WEB_TAG"
}
stages {
stage('Test') {
steps{
sh 'npm install ./node-3tier-app/api'
sh 'npm install ./node-3tier-app/web'
}
}
stage('Build Docker Image') {
steps {
sh 'docker build -f ./node-3tier-app/api/Dockerfile -t $API_IMAGE ./node-3tier-app/api'
sh 'docker build -f ./node-3tier-app/web/Dockerfile -t $WEB_IMAGE ./node-3tier-app/web'
}
}
stage('Push to ECR') {
steps {
script {
docker.withRegistry("https://${params.ECRURL}", 'ecr:us-east-1:ecr_cred') {
docker.image("$API_IMAGE").push()
docker.image("$WEB_IMAGE").push()
}
sh "docker rmi $API_IMAGE $WEB_IMAGE"
}
}
}
stage('Deploy to EKS') {
steps {
script {
withKubeConfig([credentialsId: 'default-service-account', serverUrl: "${params.EKSURL}"]) {
sh "kubectl --record deployment.apps/nodeapp-api set image deployment.v1.apps/nodeapp-api nodeapp-api=$API_IMAGE"
sh "kubectl --record deployment.apps/nodeapp-web set image deployment.v1.apps/nodeapp-web nodeapp-web=$WEB_IMAGE"
}
}
}
}
}
}