-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
65 lines (64 loc) · 2.22 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
62
63
64
65
pipeline {
agent any
tools{
maven "Maven"
}
stages {
stage('Git Checkout Slave') {
agent{label 'gceslave0'}
steps {
git branch: 'master',
url: 'https://github.com/Tailp/CICDpipeline'
}
}
stage('Maven Build') {
agent{label 'gceslave0'}
steps {
sh "mvn -Dmaven.test.skip=true install"
}
}
stage('Maven Test') {
agent{label 'gceslave0'}
steps {
sh "mvn test"
}
}
stage('Git Checkout Master') {
agent{label 'master'}
steps {
git branch: 'master',
url: 'https://github.com/Tailp/CICDpipeline'
}
}
stage('Deploy'){
agent{label 'master'}
steps {
withEnv(['GCLOUD_PATH=/home/tailp/google-cloud-sdk/bin']) {
sh '$GCLOUD_PATH/gcloud auth activate-service-account --key-file=/home/tailp/jenkinscrt/Jsonkeyfile.json'
sh '$GCLOUD_PATH/gcloud container clusters get-credentials ClusterName --zone europe-west2-c --project ProjectID'
sh '$GCLOUD_PATH/gcloud config set project ProjectID'
sh '$GCLOUD_PATH/gcloud builds submit --tag gcr.io/ProjectID/m-ci:latest .'
}
withEnv(['KUBECTL_PATH=/usr/bin']) {
sh '$KUBECTL_PATH/kubectl run mci --image=gcr.io/ProjectID/m-ci:latest --port 8080'
sh '$KUBECTL_PATH/kubectl expose deployment mci --type=LoadBalancer --port 8000 --target-port 8000'
}
}
}
stage ("Wait for checking") {
steps {
echo "Waiting 150 seconds for checking"
sleep 150// seconds
}
}
stage('Clean up') {
agent{label 'master'}
steps {
withEnv(['KUBECTL_PATH=/home/tailp/google-cloud-sdk/bin']) {
sh '$KUBECTL_PATH/kubectl delete svc mci'
sh '$KUBECTL_PATH/kubectl delete deployment mci'
}
}
}
}
}