-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathJenkinsfile-K8S-jan23
46 lines (38 loc) · 1.36 KB
/
Jenkinsfile-K8S-jan23
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
pipeline {
agent any
environment {
registry = "211223789150.dkr.ecr.us-east-1.amazonaws.com/my-docker-repo"
}
stages {
stage('Checkout') {
steps {
checkout scmGit(branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/akannan1087/springboot-app']])
}
}
stage ("build Jar") {
steps {
sh "mvn clean install"
}
}
stage ("Build image") {
steps {
script {
docker.build registry
}
}
}
stage ("Push to ECR") {
steps {
sh "aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 211223789150.dkr.ecr.us-east-1.amazonaws.com"
sh "docker push 211223789150.dkr.ecr.us-east-1.amazonaws.com/my-docker-repo:latest"
}
}
stage ("Deploy to K8S") {
steps {
withKubeConfig(caCertificate: '', clusterName: '', contextName: '', credentialsId: 'K8S', namespace: '', restrictKubeConfigAccess: false, serverUrl: '') {
sh "kubectl apply -f eks-deploy-k8s.yaml"
}
}
}
}
}