-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
64 lines (51 loc) · 1.79 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
pipeline {
agent any
environment {
PROJECT_ID = 'emerald-trilogy-313008'
CLUSTER_NAME = 'cluster-1'
LOCATION = 'europe-west6-a'
CREDENTIALS_ID = 'emerald-trilogy-313008'
}
stages {
stage('Checkout Source') {
steps {
git url:'https://github.com/mtorne/dockerProject.git', branch:'main'
}
}
stage("Build image") {
steps {
script {
myapp = docker.build("mtorne/hellowhale:${env.BUILD_ID}")
}
}
}
stage("Push image") {
steps {
script {
docker.withRegistry('https://registry.hub.docker.com', 'dockerhub') {
myapp.push("latest")
myapp.push("${env.BUILD_ID}")
}
}
}
}
stage('List pods') {
steps {
withKubeConfig([credentialsId: env.CREDENTIALS_ID]) {
sh 'curl -LO "https://storage.googleapis.com/kubernetes-release/release/v1.20.5/bin/linux/amd64/kubectl"'
sh 'chmod u+x ./kubectl'
sh 'echo $PATH'
sh 'export PATH=$PATH:/usr/local/bin/'
sh 'kubectl --help'
}
}
}
stage('Deploy to GKE') {
steps{
sh "sed -i 's/hellowhale:latest/hellowhale:${env.BUILD_ID}/g' hellowhale.yml"
sh 'export PATH=$PATH:/usr/local/bin/'
step([$class: 'KubernetesEngineBuilder', projectId: env.PROJECT_ID, clusterName: env.CLUSTER_NAME, location: env.LOCATION, manifestPattern: 'hellowhale.yml', credentialsId: env.CREDENTIALS_ID, verifyDeployments: true])
}
}
}
}