-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
58 lines (52 loc) · 1.89 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
pipeline {
agent any
environment {
AWS_ACCOUNT_ID = '971422678337'
AWS_CREDENTIALS_ID = 'aws_credentials'
AWS_REGION = 'us-east-1'
CLUSTER_NAME = 'comet-eks-cluster'
ECR_REPOSITORY = "${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com/comet-app-repo"
}
stages {
stage('Checkout') {
steps {
git 'https://github.com/Infotrend-Inc/COMET-JAVA.git'
}
}
stage('Log in to Amazon ECR') {
steps {
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: "${AWS_CREDENTIALS_ID}"]]) {
bat '''
aws ecr get-login-password --region %AWS_REGION% | docker login --username AWS --password-stdin %AWS_ACCOUNT_ID%.dkr.ecr.%AWS_REGION%.amazonaws.com
'''
}
}
}
stage('Pull Docker image') {
steps {
bat '''
docker pull %ECR_REPOSITORY%:latest
'''
}
}
stage('Update EKS kubeconfig') {
steps {
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: "${AWS_CREDENTIALS_ID}"]]) {
bat '''
aws eks update-kubeconfig --region %AWS_REGION% --name %CLUSTER_NAME%
'''
}
}
}
stage('Deploy to EKS') {
steps {
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: AWS_CREDENTIALS_ID]]) {
bat '''
kubectl set image deployment/java-app java-container=%ECR_REPOSITORY%:latest --namespace=default
kubectl rollout status deployment/java-app --namespace=default
'''
}
}
}
}
}