This repository was archived by the owner on Jan 6, 2026. It is now read-only.
forked from folio-org/folio-helm-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelm-index-charts.groovy
More file actions
76 lines (71 loc) · 3.33 KB
/
Copy pathhelm-index-charts.groovy
File metadata and controls
76 lines (71 loc) · 3.33 KB
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
#!groovy
@Library('pipelines-shared-library') _
import org.folio.Constants
import org.folio.utilities.Tools
import groovy.json.JsonSlurperClassic
import org.jenkinsci.plugins.workflow.libs.Library
properties([
buildDiscarder(logRotator(numToKeepStr: '20')),
disableConcurrentBuilds(),
pipelineTriggers([[$class: 'GitHubPushTrigger']]),
parameters([
booleanParam(name: 'indexAllCharts', defaultValue: false, description: 'Run index for all charts in folio-helm-v2 repo')
])
])
def chartsRepositoryUrl = "${Constants.FOLIO_GITHUB_URL}/folio-helm-v2.git"
List chartsForIndex
ansiColor('xterm') {
node('jenkins-agent-java11') {
try {
stage('Init') {
sshagent(credentials: [Constants.GITHUB_CREDENTIALS_ID]) {
checkout([
$class : 'GitSCM',
branches : [[name: "*/master"]],
extensions : scm.extensions + [[$class : 'SubmoduleOption',
disableSubmodules : false,
parentCredentials : false,
recursiveSubmodules: true,
reference : '',
trackingSubmodules : false]],
userRemoteConfigs: [[url: chartsRepositoryUrl]]
])
if (params.indexAllCharts) {
chartsForIndex = sh(script: "ls -d charts/*", returnStdout: true).split('\\n')
currentBuild.displayName = "Index all charts"
} else {
chartsForIndex = sh(script: "git diff HEAD~1 --name-only -- charts/ | cut -d'/' -f1-2 | sort | uniq", returnStdout: true).split('\\n')
chartsForIndex.remove("")
currentBuild.displayName = "Triggered by Github"
}
}
}
stage("Package and index charts") {
withCredentials([
usernamePassword(credentialsId: Constants.NEXUS_PUBLISH_CREDENTIALS_ID, usernameVariable: 'NEXUS_USERNAME', passwordVariable: 'NEXUS_PASSWORD'),
]) {
if (!chartsForIndex.isEmpty()) {
helm.k8sClient {
chartsForIndex.each {
sh """
echo "Pushing ${it} to repo Nexus..."
CHART_PACKAGE="\$(helm package ${it} --dependency-update | cut -d":" -f2 | tr -d '[:space:]')"
curl -is -u "${NEXUS_USERNAME}:${NEXUS_PASSWORD}" ${Constants.FOLIO_HELM_V2_REPO_URL} --upload-file "\$CHART_PACKAGE"
"""
}
}
} else {
println("No charts for indexing")
}
}
}
} catch (exception) {
println(exception)
error(exception.getMessage())
} finally {
stage('Cleanup') {
cleanWs notFailBuild: true
}
}
}
}