-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathJenkinsfile
executable file
·28 lines (28 loc) · 1.25 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
#!/usr/bin/env groovy
def branch = 'master'
def repo = "https://github.com/cvemula1/K8s-Docker-Jenkins-CICD.git"
podTemplate(label: 'default'){
node('default') {
stage ("build") {
container('default') {
git repo
sh "apt-get install -y openjdk-8-jdk"
sh "mvn clean install"
sh "aws ecr get-login --no-include-email --region us-west-2 > loginCommand.sh"
sh readFile('loginCommand.sh').trim()
sh "docker build -t helloworld ."
sh "docker tag helloworld:latest <AwsAccountid>.dkr.ecr.us-west-2.amazonaws.com/helloworld:$BUILD_NUMBER"
sh "docker tag helloworld:latest <AwsAccountid>.dkr.ecr.us-west-2.amazonaws.com/helloworld:latest"
sh "docker push <AwsAccountid>.dkr.ecr.us-west-2.amazonaws.com/helloworld:$BUILD_NUMBER"
sh "docker push <AwsAccountid>.dkr.ecr.us-west-2.amazonaws.com/helloworld:latest"
}
}
stage ("deploy") {
container('default'){
sh "kubectl apply -f Kubernetes/deployment.yaml -n <Kubernetes-NameSpace>"
sh "kubectl apply -f Kubernetes/services.yaml -n <Kubernetes-NameSpace>"
sh "kubectl apply -f Kubernetes/ingress.yaml -n <Kubernetes-NameSpace>"
}
}
}
}