diff --git a/CHANGELOG.md b/CHANGELOG.md index be7b48072..66af1a6b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased * Fix documentation refers to qs with prefix infra- however there are only inf- quickstarters ([#1060](https://github.com/opendevstack/ods-jenkins-shared-library/issues/1060)) * Fix Tailor deployment drifts for D, Q envs ([#1055](https://github.com/opendevstack/ods-jenkins-shared-library/pull/1055)) +* Fix Globally injected variables do not work in subcharts/dependencies ([#1066](https://github.com/opendevstack/ods-jenkins-shared-library/issues/1066)) * Update api version in ocp templates for image, buildconfig, route and deploymentconfig ([#1072](https://github.com/opendevstack/ods-jenkins-shared-library/issues/1072)) ## [4.3.4] - 2024-02-20 diff --git a/src/org/ods/component/HelmDeploymentStrategy.groovy b/src/org/ods/component/HelmDeploymentStrategy.groovy index 15780f8ab..7811150ba 100644 --- a/src/org/ods/component/HelmDeploymentStrategy.groovy +++ b/src/org/ods/component/HelmDeploymentStrategy.groovy @@ -126,9 +126,21 @@ class HelmDeploymentStrategy extends AbstractDeploymentStrategy { // we persist the original ones set from outside - here we just add ours Map mergedHelmValues = [:] mergedHelmValues << options.helmValues + + // we add the global ones - this allows usage in subcharts + // TODO: is this really needed? - we could use *just* the global ones + // TODO: how do we know we are not overriding something the user defined? + options.helmValues.each { key, value -> + mergedHelmValues["global.${key}"] = value + } + mergedHelmValues['imageNamespace'] = targetProject mergedHelmValues['imageTag'] = options.imageTag + // we also add the predefined ones as these are in use by the library + mergedHelmValues['global.imageNamespace'] = targetProject + mergedHelmValues['global.imageTag'] = options.imageTag + // deal with dynamic value files - which are env dependent def mergedHelmValuesFiles = [] mergedHelmValuesFiles.addAll(options.helmValuesFiles) diff --git a/src/org/ods/orchestration/phases/DeployOdsComponent.groovy b/src/org/ods/orchestration/phases/DeployOdsComponent.groovy index bbbd38cfa..2244026c1 100644 --- a/src/org/ods/orchestration/phases/DeployOdsComponent.groovy +++ b/src/org/ods/orchestration/phases/DeployOdsComponent.groovy @@ -190,7 +190,10 @@ class DeployOdsComponent { Map helmMergedValues = [ "imageTag": project.targetTag, "imageNamespace": project.targetProject, - "componentId": deploymentMean.repoId + "componentId": deploymentMean.repoId, + "global.imageTag": project.targetTag, + "global.imageNamespace": project.targetProject, + "global.componentId": deploymentMean.repoId ] // take the persisted ones. helmMergedValues << deploymentMean.helmValues diff --git a/test/groovy/vars/OdsComponentStageRolloutOpenShiftDeploymentSpec.groovy b/test/groovy/vars/OdsComponentStageRolloutOpenShiftDeploymentSpec.groovy index b444b9170..9bffdc955 100644 --- a/test/groovy/vars/OdsComponentStageRolloutOpenShiftDeploymentSpec.groovy +++ b/test/groovy/vars/OdsComponentStageRolloutOpenShiftDeploymentSpec.groovy @@ -204,7 +204,7 @@ class OdsComponentStageRolloutOpenShiftDeploymentSpec extends PipelineSpockTestB buildArtifacts.size() > 0 buildArtifacts.deployments['bar-deploymentMean']['type'] == 'helm' - 1 * openShiftService.helmUpgrade('foo-dev', 'bar', ['values.yaml'], ['registry':null, 'componentId':'bar', 'imageNamespace':'foo-dev', 'imageTag':'cd3e9082'], ['--install', '--atomic'], [], true) + 1 * openShiftService.helmUpgrade('foo-dev', 'bar', ['values.yaml'], ['registry':null, 'componentId':'bar', 'global.registry':null, 'global.componentId':'bar', 'imageNamespace':'foo-dev', 'imageTag':'cd3e9082', 'global.imageNamespace':'foo-dev', 'global.imageTag':'cd3e9082'], ['--install', '--atomic'], [], true) } @Unroll