-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
45 lines (38 loc) · 1.73 KB
/
Jenkinsfile
File metadata and controls
45 lines (38 loc) · 1.73 KB
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
pipeline {
agent none
stages {
stage('Build and Jib') {
agent {
label 'java11' // Use an agent with the "java11" label
}
steps {
// Build project including tests & analytics
sh './gradlew build'
// Create and publish a Docker image using Jib with GCR auth present
withCredentials([file(credentialsId: 'gcr-service-user-proto-client-ttf', variable: 'GOOGLE_APPLICATION_CREDENTIALS')]) {
sh './gradlew --console=plain jib' // Jib outputs some gibberish progress logging we skip with "plain"
}
// Customize Kubernetes manifests for deployment
sh './gradlew prepareCD'
// Stash the modified 'k8s' directory so we can use it in the next stage
stash includes: 'k8s/**', name: 'k8s-stash'
}
}
stage('Deploy to Kubernetes') {
agent {
label 'kubectl' // Use an agent with the "kubectl" label
}
steps {
// On the second agent, unstash the 'k8s' directory
unstash 'k8s-stash'
sh 'ls -la k8s'
// Deploy to Kubernetes
withKubeConfig(clusterName: 'ttf-cluster', contextName: 'jenkins-k8s', credentialsId: '1c00907c-98ab-4c55-bd44-7afc075d4ac8', namespace: '', restrictKubeConfigAccess: false, serverUrl: 'https://kubernetes.default') {
sh 'kubectl get ns'
sh 'kubectl create ns testytest || true' // Don't break if namespace already exists
sh 'kubectl apply -f k8s/ -n testytest'
}
}
}
}
}