-
Notifications
You must be signed in to change notification settings - Fork 110
/
Copy pathJenkinsfile-k8s-deploy
27 lines (23 loc) · 1.01 KB
/
Jenkinsfile-k8s-deploy
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
pipeline {
agent any
stages {
stage('Build Image') {
steps {
sh "docker build --no-cache --build-arg='GIT_COMMIT_ID=${env.GIT_COMMIT}' -t brainupgrade/request-logger:${env.GIT_COMMIT} -f Dockerfile-multi ."
sh "docker tag brainupgrade/request-logger:${env.GIT_COMMIT} brainupgrade/request-logger:latest"
}
}
}
post {
success {
withCredentials([usernamePassword(credentialsId: 'docker-hub-credentials', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh "docker login -u ${USERNAME} -p ${PASSWORD}"
sh "docker push brainupgrade/request-logger:${env.GIT_COMMIT}"
sh "docker push brainupgrade/request-logger:latest"
sh "kubectl get deploy logger || kubectl create deploy logger --image brainupgrade/request-logger:${env.GIT_COMMIT}"
sh "kubectl set image deploy logger request-logger=brainupgrade/request-logger:${env.GIT_COMMIT}"
sh "kubectl set env deploy logger BUILD_ID=${env.BUILD_ID}"
}
}
}
}