-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
67 lines (67 loc) · 2.77 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
pipeline {
agent {
kubernetes {
inheritFrom 'shared'
yaml libraryResource("pod-templates/helm.yaml")
}
}
stages {
stage('Prepare') {
steps {
container('chart-testing') {
sh 'helm repo add stable https://charts.helm.sh/stable'
sh 'helm repo add molgenis https://helm.molgenis.org'
sh 'helm repo add bitnami https://charts.bitnami.com/bitnami'
}
}
}
stage('Test and package [PR]') {
when {
changeRequest()
}
environment {
CT_REMOTE = 'origin'
CT_BUILD_ID = "${CHANGE_ID}"
}
steps {
container('chart-testing') {
sh "git fetch --no-tags origin ${CHANGE_TARGET}:refs/remotes/origin/${CHANGE_TARGET}"
sh "ct lint --validate-maintainers=false --target-branch ${CHANGE_TARGET}"
sh 'mkdir target'
sh 'for dir in $(ct list-changed --target-branch ${CHANGE_TARGET}); do helm package --destination target "$dir"; done'
}
}
}
stage('Test and package [master]') {
when {
branch 'master'
}
steps {
container('chart-testing') {
sh 'ct lint --all --validate-maintainers=false'
sh 'mkdir target'
sh 'for dir in charts/*; do helm package --destination target "$dir"; done'
}
}
}
stage('Deploy to nexus and chartmuseum') {
when {
branch 'master'
}
steps {
container('vault') {
script {
env.NEXUS_USER = sh(script: 'vault read -field=username secret/ops/account/nexus', returnStdout: true)
env.NEXUS_PWD = sh(script: 'vault read -field=password secret/ops/account/nexus', returnStdout: true)
env.CHARTMUSEUM_USER = sh(script: 'vault read -field=username secret/ops/account/chartmuseum', returnStdout: true)
env.CHARTMUSEUM_PWD = sh(script: 'vault read -field=password secret/ops/account/chartmuseum', returnStdout: true)
}
}
container('alpine') {
sh 'set +x; for chart in target/*; do curl -L --fail -u $NEXUS_USER:$NEXUS_PWD $HELM_REPO --upload-file "$chart"; done'
sh 'set +x; for chart in target/*; do curl -L --fail -u $CHARTMUSEUM_USER:$CHARTMUSEUM_PWD ${HELM_REPOSITORY}api/charts --data-binary "@$chart"; done'
}
}
}
}
}