-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile.helm.groovy
61 lines (58 loc) · 1.73 KB
/
Jenkinsfile.helm.groovy
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
pipeline {
environment {
KEYVAULT = 'ai-devops-azverpjq'
KUBE_CONFIG_PATH = './kubeconfig'
HELM_EXPERIMENTAL_OCI = 1
}
agent any
stages {
stage('Checkout Helm Code') {
steps {
git branch: "${params.source_code_branch}", credentialsId: "${params.github_token_credential}", url: "${params.source_code_repository_url}"
echo "Checkout helm code done ${source_code_repository_url}"
}
}
stage('helm config and login by cloud') {
steps {
sh "helm version"
}
}
stage('helm package') {
steps {
sh "helm lint ${params.helm_package_folder}"
sh "helm package ${params.helm_package_folder}"
}
}
stage('helm push') {
// when { tag "release-*" }
environment {
tag = gitTagName()
}
steps {
echo "helm is pushing to helm repository:"
sh "helm push ${parames.helm_chart_name}-${tag}.tgz oci://${parames.helm_repository} --kubeconfig ${KUBE_CONFIG_PATH}"
echo "helm pushed new version ${tag}"
}
}
}
}
String gitTagName() {
commit = getCommit()
if (commit) {
desc = sh(script: "git describe --tags ${commit}", returnStdout: true)?.trim()
if (isTag(desc)) {
return desc
}
}
return null
}
String getCommit() {
return sh(script: 'git rev-parse HEAD', returnStdout: true)?.trim()
}
@NonCPS
boolean isTag(String desc) {
match = desc =~ /.+-[0-9]+-g[0-9A-Fa-f]{6,}$/
result = !match
match = null // prevent serialisation
return result
}