forked from artisantek/docker-sample-java-webapp
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathJenkinsfile
More file actions
49 lines (44 loc) · 1.7 KB
/
Jenkinsfile
File metadata and controls
49 lines (44 loc) · 1.7 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
pipeline {
agent any
environment {
AWS_REGION = 'ap-south-1'
REPO_NAME = 'java-webapp'
IMAGE_TAG = 'latest'
AWS_ACCOUNT_ID = '039483717602'
IMAGE_URI = "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/${REPO_NAME}:${IMAGE_TAG}"
}
stages {
stage('Checkout Source Code') {
steps {
git url: 'https://github.com/bhagyashreep032/docker-sample-java-webapp.git'
}
}
stage('Build Docker Image') {
steps {
sh 'docker build -t $IMAGE_URI .'
}
}
stage('Login to ECR & Push Image') {
steps {
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: 'aws-ecr-creds']]) {
sh '''
aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin 039483717602.dkr.ecr.ap-south-1.amazonaws.com
docker push 039483717602.dkr.ecr.ap-south-1.amazonaws.com/java-webapp:latest
'''
}
}
}
stage('Deploy to EKS via Helm') {
steps {
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: 'aws-ecr-creds']]) {
sh '''
aws eks update-kubeconfig --name my-demo-cluster --region ap-south-1
helm upgrade --install java-webapp ./helm \
--set image.repository=039483717602.dkr.ecr.ap-south-1.amazonaws.com/java-webapp \
--set image.tag=latest
'''
}
}
}
}
}