-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
39 lines (39 loc) · 1.11 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
pipeline {
agent any
stages {
stage('Docker Build') {
steps {
sh "docker build -t tapan2609/sbmvnpodinfo:${env.BUILD_NUMBER} ."
}
}
stage('Docker Push') {
steps {
withCredentials([usernamePassword(credentialsId: 'docker098765', passwordVariable: 'dockerHubPassword', usernameVariable: 'dockerHubUser')]) {
sh "docker login -u ${env.dockerHubUser} -p ${env.dockerHubPassword}"
sh "docker push tapan2609/sbmvnpodinfo:${env.BUILD_NUMBER}"
}
}
}
stage('Docker Remove Image') {
steps {
sh "docker rmi tapan2609/sbmvnpodinfo:${env.BUILD_NUMBER}"
}
}
stage('Apply Kubernetes Files') {
steps {
withKubeConfig([credentialsId: 'kubeconfig']) {
sh 'cat deployment.yaml | sed "s/{{BUILD_NUMBER}}/$BUILD_NUMBER/g" | kubectl apply -f -'
sh 'kubectl apply -f service.yaml'
}
}
}
}
post {
success {
slackSend(message: "sbmvn Pipeline is successfully completed.")
}
failure {
slackSend(message: "sbmvn Pipeline failed. Please check the logs.")
}
}
}