-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
65 lines (46 loc) · 2.72 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
#!groovy
podTemplate(label: 'pod-personal-website', containers: [
containerTemplate(name: 'hugo', image: 'hugomods/hugo:latest', ttyEnabled: true, command: 'cat'),
containerTemplate(name: 'helm', image: 'alpine/helm', ttyEnabled: true, command: 'cat'),
containerTemplate(name: 'kaniko', image: 'gcr.io/kaniko-project/executor:debug', imagePullPolicy: 'Always', command: 'sleep', args: '9999999')
],
volumes: [
hostPathVolume(hostPath: '/tmp', mountPath: '/tmp', readOnly: false),
hostPathVolume(hostPath: '/var/run/docker.sock', mountPath: '/var/run/docker.sock', readOnly: false),
secretVolume(secretName: 'kube-config', mountPath: '/root/.kube'),
secretVolume(secretName: 'docker-config', mountPath: '/kaniko/.docker')
]
)
{
node('pod-personal-website') {
def DOCKER_HUB_ACCOUNT = 'aksine'
def DOCKER_IMAGE_NAME = 'personal-website'
def K8S_DEPLOYMENT_NAME = 'personal-website'
def DOCKER_BUILD_CONTEXT = '/home/jenkins/agent/workspace/Hugo' // Specify your desired build context directory
// Make the workspace writable
stage('Clone Hugo App Repository') {
checkout scm
container('hugo') {
stage('Build Hugo Site') {
sh ("mkdir -p ./cache")
sh ("hugo -s ./blog/ -d ../public/ ")
}
}
container('kaniko') {
stage('Docker Build & Push Current & Latest Versions') {
sh "/kaniko/executor -f `pwd`/Dockerfile -c `pwd` --cache=true --destination=${DOCKER_HUB_ACCOUNT}/${DOCKER_IMAGE_NAME}:${env.BUILD_NUMBER}"
}
}
container('helm') {
stage('Install on Doha cluster') {
sh ("helm repo add bjw-s-charts https://bjw-s.github.io/helm-charts/")
sh "helm upgrade personal-website bjw-s-charts/app-template -i -f Helm.yml --kube-context doh --set-string controllers.main.containers.main.image.tag=${env.BUILD_NUMBER}"
}
stage('Install on Aus cluster') {
sh ("helm repo add bjw-s-charts https://bjw-s.github.io/helm-charts/")
sh "helm upgrade personal-website bjw-s-charts/app-template -i -f Helm.yml --kube-context aus --set-string controllers.main.containers.main.image.tag=${env.BUILD_NUMBER}"
}
}
}
}
}