-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
44 lines (36 loc) · 1.68 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
40
41
42
43
44
podTemplate(label: 'mypod', containers: [
containerTemplate(name: 'docker', image: 'docker', ttyEnabled: true, command: 'cat'),
containerTemplate(name: 'kubectl', image: 'lachlanevenson/k8s-kubectl:v1.7.3', command: 'cat', ttyEnabled: true)
],
volumes: [
hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock'),
]) {
node('mypod') {
checkout scm
stage('build and push the bot image') {
container('docker') {
withCredentials([[$class: 'UsernamePasswordMultiBinding',
credentialsId: 'dockerhub',
usernameVariable: 'DOCKER_HUB_USER',
passwordVariable: 'DOCKER_HUB_PASSWORD']]) {
sh """
cd bot
docker build -t ${env.DOCKER_HUB_USER}/bot-service:${env.BUILD_NUMBER} .
"""
sh "docker login -u ${env.DOCKER_HUB_USER} -p ${env.DOCKER_HUB_PASSWORD} "
sh "docker push ${env.DOCKER_HUB_USER}/bot-service:${env.BUILD_NUMBER} "
}
}
}
stage('update kubernetes deployment for bot') {
container('kubectl') {
withCredentials([[$class: 'UsernamePasswordMultiBinding',
credentialsId: 'dockerhub',
usernameVariable: 'DOCKER_HUB_USER',
passwordVariable: 'DOCKER_HUB_PASSWORD']]) {
sh "kubectl set image deployment/bot-service bot-service=${env.DOCKER_HUB_USER}/bot-service:${env.BUILD_NUMBER} "
}
}
}
}
}