-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathJenkinsfile
47 lines (46 loc) · 1.76 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
pipeline {
agent {
kubernetes {
label 'mypod'
defaultContainer 'jnlp'
yamlFile 'podTemplate.yaml'
}
}
triggers {
eventTrigger simpleMatch('dcanadillas/kaniko-petclinic:latest')
}
stages {
stage('Deploy') {
steps {
container('kubectl') {
echo 'Deploying k8 app'
//sh 'kubectl get pods -n staging'
sh 'kubectl get deployments -n staging'
// Let's delete deployment petclinic if still deployed
// We want to do a fresh deployment of the image
sh '''
MYDEPLOY=$(kubectl get deployments -n staging | awk '/^petclinic/ {print $1}')
if [ "$MYDEPLOY" = "petclinic" ];then kubectl delete deployment -n staging $MYDEPLOY; fi
'''
sh 'kubectl apply -f test-deploy.yaml -n staging'
// Now let's check all the deployments again
sh 'kubectl get deployments -n staging'
echo 'Spring Petclinic app has been deployed'
}
}
}
stage('Check') {
steps {
//error 'Fake error to force failure in Build'
container('kubectl') {
//copyArtifacts projectName: '../petclinic-kaniko/master'
//gateConsumesArtifact id: 'kaniko'
//error 'Forcing error to check DevOptics'
echo 'Check Deployment and Service'
sh 'kubectl get deployments,svc -n staging'
sh 'kubectl describe deployment petclinic -n staging'
}
}
}
}
}