From 7b3d7fa5d713ff393bbb5a71a1e5c3ce27d55b9a Mon Sep 17 00:00:00 2001 From: serverhorror Date: Tue, 20 Feb 2024 10:37:09 +0100 Subject: [PATCH 1/3] Inject `global.*` values to make them available to release manager --- CHANGELOG.md | 1 + src/org/ods/component/HelmDeploymentStrategy.groovy | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85e7a9629..d0d857bad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased * 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)) ## [4.3.4] - 2024-02-20 diff --git a/src/org/ods/component/HelmDeploymentStrategy.groovy b/src/org/ods/component/HelmDeploymentStrategy.groovy index eb43c80aa..ec43125b6 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) From 5754a765d6447c115a870181da3dd87ab3b69780 Mon Sep 17 00:00:00 2001 From: serverhorror Date: Tue, 20 Feb 2024 10:41:30 +0100 Subject: [PATCH 2/3] Make `global.*` values available in DeployOdsComponent --- src/org/ods/orchestration/phases/DeployOdsComponent.groovy | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/org/ods/orchestration/phases/DeployOdsComponent.groovy b/src/org/ods/orchestration/phases/DeployOdsComponent.groovy index ab9ff8245..24e1f51b7 100644 --- a/src/org/ods/orchestration/phases/DeployOdsComponent.groovy +++ b/src/org/ods/orchestration/phases/DeployOdsComponent.groovy @@ -188,7 +188,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 From f5550e2227a8630737d2a15e1f7b29dd4615ba66 Mon Sep 17 00:00:00 2001 From: serverhorror Date: Tue, 20 Feb 2024 10:48:44 +0100 Subject: [PATCH 3/3] Fix test `run successfully with Helm` --- .../vars/OdsComponentStageRolloutOpenShiftDeploymentSpec.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/groovy/vars/OdsComponentStageRolloutOpenShiftDeploymentSpec.groovy b/test/groovy/vars/OdsComponentStageRolloutOpenShiftDeploymentSpec.groovy index a1aa0ca99..d36ad4f0e 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