/** * Bumps the patch version in Chart.yaml, updates appVersion and values.yaml image tag. * Must be called inside container('tools') block (needs sed + git). * * config keys: * imageTag (required) - new image tag to write into values.yaml * chartFile (optional) - path to Chart.yaml, default: manifest/helm/Chart.yaml * valuesFile (optional) - path to values.yaml, default: manifest/helm/values.yaml */ def call(Map config) { def imageTag = config.imageTag if (!imageTag) error('bumpHelmChart: imageTag is required') def chartFile = config.chartFile ?: 'manifest/helm/Chart.yaml' def valuesFile = config.valuesFile ?: 'manifest/helm/values.yaml' def content = readFile(chartFile) def matcher = content =~ /version:\s+(\d+)\.(\d+)\.(\d+)/ if (!matcher) error("bumpHelmChart: could not parse version in ${chartFile}") def newVersion = "${matcher[0][1]}.${matcher[0][2]}.${(matcher[0][3] as int) + 1}" sh "sed -i 's/^version: .*/version: ${newVersion}/' ${chartFile}" sh "sed -i 's/^appVersion: .*/appVersion: \"${imageTag}\"/' ${chartFile}" sh "sed -i 's/^ tag: .*/ tag: ${imageTag}/' ${valuesFile}" }