-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathJenkinsfile
executable file
·78 lines (66 loc) · 2.28 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
66
67
68
69
70
71
72
73
74
75
76
77
78
properties([pipelineTriggers([githubPush()])])
pipeline {
options {
disableConcurrentBuilds()
buildDiscarder(logRotator(numToKeepStr: '10'))
timeout(time: 30, unit: 'MINUTES')
}
agent {
kubernetes {
label 'worker-aws-credentials-broker'
inheritFrom 'kaniko-slim'
containerTemplates([
containerTemplate(name: 'helm', image: "flowcommerce/k8s-build-helm2:0.0.48", command: 'tail', args: '-f /dev/null', ttyEnabled: true)
])
}
}
environment {
ORG = 'flowcommerce'
APP_NAME = 'aws-credentials-broker'
}
stages {
stage('Checkout') {
steps {
checkoutWithTags scm
script {
VERSION = new flowSemver().calculateSemver()
}
}
}
stage('Commit SemVer tag') {
when { branch 'main' }
steps {
script {
new flowSemver().commitSemver(VERSION)
}
}
}
stage('Build and push docker image release') {
when { branch 'main' }
steps {
container('kaniko') {
script {
semver = VERSION.printable()
sh """
/kaniko/executor -f `pwd`/Dockerfile -c `pwd` \
--snapshot-mode=redo --use-new-run \
--destination ${env.ORG}/aws-credentials-broker:$semver
"""
}
}
}
}
stage('Deploy Helm chart') {
when { branch 'main' }
steps {
container('helm') {
sh(script: """sed -i 's/^appVersion:.*\$/appVersion: "${VERSION.printable()}"/' deploy/aws-credentials-broker*/Chart.yaml""") //XXX: This is the only way to actually set the app version with today's helm
sh('helm init --client-only')
sh('helm plugin install https://github.com/futuresimple/helm-secrets || true')
sh("helm secrets upgrade --dry-run --wait --install --debug --namespace production --set deployments.live.version=${VERSION.printable()} aws-credentials-broker -f deploy/aws-credentials-broker/secrets.yaml ./deploy/aws-credentials-broker")
sh("helm secrets upgrade --wait --install --debug --namespace production --set deployments.live.version=${VERSION.printable()} aws-credentials-broker -f deploy/aws-credentials-broker/secrets.yaml ./deploy/aws-credentials-broker")
}
}
}
}
}