-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
61 lines (59 loc) · 1.51 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
55
56
57
58
59
60
61
pipeline {
environment {
PROJECT = "trainee-2020-6-nardosalem"
APP_NAME = "findit"
NAMESPACE = "findit"
IMAGE_TAG = "gcr.io/${PROJECT}/${APP_NAME}:${env.BRANCH_NAME}.${BUILD_NUMBER}"
}
agent {
kubernetes {
defaultContainer 'jnlp'
yaml '''
apiVersion: v1
kind: Pod
spec:
serviceAccountName: my-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 & Push') {
steps {
container('gcloud'){
sh ('gcloud builds submit -t ${IMAGE_TAG} .')
}
}
}
stage ("Deployment"){
steps{
container ("kubectl"){
sh("sed -i.bak 's#gcr.io/gcr-project/sample:1.0.0#${IMAGE_TAG}#' ./deployment/deploy.yaml")
sh("kubectl --namespace=${NAMESPACE} apply -f ./deployment/deploy.yaml")
sh("kubectl --namespace=${NAMESPACE} apply -f ./deployment/service.yaml")
sh("kubectl --namespace=${NAMESPACE} apply -f ./deployment/ingress.yaml")
}
}
}
stage ("Testing. . ."){
steps{
sh 'echo Testing. . .'
}
}
stage ("Deploy. . ."){
steps{
sh 'echo Deploying. . .'
}
}
}
}