-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
54 lines (52 loc) · 1.46 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
45
46
47
48
49
50
51
52
53
54
def project = 'cryptobeer'
def appName = 'cryptobeer'
def property = "${params.PROPERTIES}"
def imageTag = "gcr.io/${project}/${appName}-telegram-bot:${env.BUILD_NUMBER}"
pipeline {
agent {
kubernetes {
label 'jenkins-backend'
defaultContainer 'jnlp'
yaml """
apiVersion: v1
kind: Pod
metadata:
labels:
component: ci
spec:
# Use service account that can deploy to all namespaces
serviceAccountName: cd-jenkins
containers:
- name: gcloud
image: gcr.io/cloud-builders/gcloud
command:
- cat
tty: true
- name: kubectl
image: gcr.io/cloud-builders/kubectl
command:
- cat
tty: true
"""
}
}
stages {
stage('Build and Push docker image to GCR') {
steps {
container('gcloud') {
sh "sed -i.bak 's#--spring.profiles.active=#--spring.profiles.active=${property}#' Dockerfile"
sh "gcloud builds submit -t ${imageTag} ."
}
}
}
stage('Deploy') {
steps {
container('kubectl') {
sh("sed -i.bak 's#gcr.io/${project}/${appName}-telegram-bot:1#${imageTag}#' ./k8s/deploy/deploy-telegram-bot.yaml")
sh("kubectl apply -f k8s/deploy/")
sh("kubectl apply -f k8s/service/")
}
}
}
}
}