-
Notifications
You must be signed in to change notification settings - Fork 2
/
.jenkins
66 lines (55 loc) · 1.7 KB
/
.jenkins
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
def getTagName() {
return "${env.BRANCH_NAME}".replace('/', '-')
}
pipeline {
agent any
environment {
IMAGE_NAME = 'silph/silph-bot'
IMAGE_TAG = getTagName()
DEPLOY = 'deploy/silph-bot'
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Build Image') {
steps {
sh '''
docker build . \
-t $IMAGE_NAME:$IMAGE_TAG \
-t $IMAGE_NAME:$IMAGE_TAG.$BUILD_NUMBER
'''
}
}
stage('Publish Image') {
steps {
withDockerRegistry(registry: [credentialsId: 'dockerhub']) {
sh 'docker push $IMAGE_NAME:$IMAGE_TAG'
sh 'docker push $IMAGE_NAME:$IMAGE_TAG.$BUILD_NUMBER'
}
}
}
stage('Deploy') {
when {
buildingTag()
}
environment {
KUBECONFIG = credentials('kube-config')
NAMESPACE = 'silph-bots'
}
steps {
sh 'kubectl --namespace $NAMESPACE set image $DEPLOY silph-bot=$IMAGE_NAME:$TAG_NAME'
}
post {
success {
discordSend description: "", title: "silph-bot ${env.TAG_NAME} has been deployed", result: 'SUCCESS', link: "${env.RUN_DISPLAY_URL}", footer: 'build.silph.io', webhookURL: 'https://discordapp.com/api/webhooks/752970236331819081/TdglUImHWn5Xttzp1faEC9EKw82plrsdkRj92r9XjNGOmyjdgNXTqFgizlpdUEHp0Wbd'
}
failure {
discordSend description: "", title: "silph-bot ${env.TAG_NAME} failed deploy", result: 'FAILURE', footer: 'build.silph.io', link: "${env.RUN_DISPLAY_URL}", webhookURL: 'https://discordapp.com/api/webhooks/752970236331819081/TdglUImHWn5Xttzp1faEC9EKw82plrsdkRj92r9XjNGOmyjdgNXTqFgizlpdUEHp0Wbd'
}
}
}
}
}