Skip to content

Commit ee2bbd1

Browse files
author
lerndevops
authored
Create Jenkinsfilek8s
1 parent 86f7fe6 commit ee2bbd1

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

Jenkinsfilek8s

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
pipeline {
2+
agent any
3+
stages {
4+
stage('checkout repo') {
5+
steps {
6+
git url: 'https://github.com/lerndevops/DevOpsClassCodes.git '
7+
}
8+
}
9+
stage('build artifact') {
10+
steps {
11+
sh 'mvn clean package'
12+
}
13+
}
14+
stage('build docker image') {
15+
steps {
16+
sh 'docker build -t lerndevops/addressbook .'
17+
}
18+
}
19+
stage('push docker image') {
20+
steps {
21+
withCredentials([string(credentialsId: 'DOCKER_HUB_PWD', variable: 'DOCKER_HUB_PWD')]) {
22+
sh "docker login -u lerndevops -p ${DOCKER_HUB_PWD}"
23+
}
24+
sh 'docker push lerndevops/addressbook'
25+
}
26+
}
27+
stage('Deploy to K8s') {
28+
steps {
29+
sh 'kubectl apply -f addressbook-deploy-k8s.yml'
30+
}
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)