-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathJenkinsfile
77 lines (77 loc) · 3.58 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
pipeline {
agent {
kubernetes {
// the shared pod template defined on the Jenkins server config
inheritFrom 'shared'
// helm pod template defined in molgenis/molgenis-jenkins-pipeline repository
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 elastic https://helm.elastic.co/"
sh "helm repo add fusionauth https://fusionauth.github.io/charts"
sh "helm repo add bitnami https://charts.bitnami.com/bitnami"
sh "helm repo add jenkins https://charts.jenkins.io"
sh "helm repo add minio https://helm.min.io"
sh 'helm repo add jupyter https://jupyterhub.github.io/helm-chart'
sh 'helm repo add nfs https://kubernetes-sigs.github.io/nfs-subdir-external-provisioner'
sh "helm repo add airflow https://airflow-helm.github.io/charts"
sh "helm repo add grafana https://grafana.github.io/helm-charts"
}
}
}
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'
}
}
}
}
}