-
Notifications
You must be signed in to change notification settings - Fork 3
/
Jenkinsfile
46 lines (43 loc) · 1.53 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
node {
stage('checkout') {
deleteDir()
checkout scm
if ("${env.BRANCH_NAME}" != 'null') {
sh "git checkout -b ${env.BRANCH_NAME}"
}
gitCommit = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
}
stage('build') {
build_env = docker.build("local/build_env")
}
build_env.inside {
stage('test') {
sh '''
helm init --client-only
helm lint charts/*
'''
charts = sh(returnStdout: true, script: "git diff-tree --no-commit-id --name-only -a -r ${gitCommit} | cut -d\'/\' -f1,2 | uniq | grep \"^charts\" | xargs -n1 -r").trim()
}
if (charts) {
stage('package') {
// Package Charts
sh """
helm init --client-only
helm package --destination docs ${charts}
helm repo index --url https://harbur.github.io/kubernetic-charts/ docs
"""
// Push to Git repository
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'github', passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME']]) {
sh """
# Configure Git CLI
git config --global user.email jenkins@cloud
git config --global user.name jenkins
# Push Packages to Git
git commit -am "packaging charts"
git push -u https://${env.USERNAME}:${env.PASSWORD}@github.com/harbur/kubernetic-charts.git ${env.BRANCH_NAME}
"""
}
}
}
}
}