-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
62 lines (56 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
pipeline {
agent any
environment {
GOOGLE_PROJECT_ID = "playground-111111"
}
stages {
stage("Stage 1 - Version Verification Stage") {
steps {
echo "Checking Versions..."
sh "docker --version"
sh "git version"
sh "node -v"
sh "npm -v"
sh "gcloud version"
}
}
stage("Stage 2 - Cloning GitHub Repo Into Jenkins...") {
steps {
git branch: "master",
url:"https://github.com/bhavgandhi/collabotomate-high-5s.git"
sh "ls"
}
}
stage("Stage 2.1 - NodeJS TEST + NPM Test + Sonar Code Analysis...") {
steps {
sh "node --trace-deprecation"
sh "npm install"
sh "npm run test"
sh "ls"
sh "npm run sonar"
sh "ls"
}
}
stage("Stage 3 - Package Application using Docker and storing the image in registry..") {
steps {
echo "Running ${env.BUILD_ID} on ${env.JENKINS_URL}"
sh "gcloud builds submit --tag=gcr.io/${GOOGLE_PROJECT_ID}/jenkins-pipe-external:v1.${env.BUILD_ID} . "
}
}
stage("Stage 4 - Deployment - Kubernetes Cluster - Set the image in the repo to latest") {
steps {
echo "Installing Kubernetes Cluster"
sh "pwd"
sh "ls"
sh "gcloud container clusters get-credentials deloitte-drifters-demo-cluster --zone us-central1-a --project ${GOOGLE_PROJECT_ID}"
sh "kubectl version"
sh "kubectl get namespaces"
echo "kubectl set image deployment/deloitte-drifters-frontend deloitte-drifters-frontend=gcr.io/${GOOGLE_PROJECT_ID}/jenkins-pipe-external:v1.${env.BUILD_ID} --record --namespace=master"
sh "kubectl set image deployment/deloitte-drifters-frontend deloitte-drifters-frontend=gcr.io/${GOOGLE_PROJECT_ID}/jenkins-pipe-external:v1.${env.BUILD_ID} --record --namespace=master"
sh "kubectl get deployments -n master"
sh "kubectl get pods -n master"
sh "kubectl get services -n master"
}
}
}
}