diff --git a/CHANGELOG.md b/CHANGELOG.md index 95f0dea13f..2a838868cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ ### Fixed * Fix Tailor deployment drifts for D, Q envs ([#1055](https://github.com/opendevstack/ods-jenkins-shared-library/pull/1055)) +* Aqua Stage is being skipped when branches are not eligable ([#1170](https://github.com/opendevstack/ods-jenkins-shared-library/pull/1170)) ## [4.6.0] - 2024-10-23 diff --git a/test/groovy/vars/OdsComponentStageScanWithAquaSpec.groovy b/test/groovy/vars/OdsComponentStageScanWithAquaSpec.groovy index b270584cb1..6a74f4c523 100644 --- a/test/groovy/vars/OdsComponentStageScanWithAquaSpec.groovy +++ b/test/groovy/vars/OdsComponentStageScanWithAquaSpec.groovy @@ -295,4 +295,41 @@ class OdsComponentStageScanWithAquaSpec extends PipelineSpockTestBase { assertJobStatusSuccess() } + def "forwards branches config into ScanWithAquaStage"() { + given: + def c = config + [environment: 'dev'] + IContext context = new Context(null, c, logger) + + OpenShiftService openShiftService = Stub(OpenShiftService.class) + openShiftService.getConfigMapData('ods', ScanWithAquaStage.AQUA_CONFIG_MAP_NAME) >> [ + enabled: true, alertEmails: "mail1@mail.com", url: "http://aqua", registry: "internal" + ] + openShiftService.getConfigMapData("foo", ScanWithAquaStage.AQUA_CONFIG_MAP_NAME) >> [enabled: true] + ServiceRegistry.instance.add(OpenShiftService, openShiftService) + + and: "spy the stage constructor to capture the inherited config" + Map capturedCfg = null + GroovySpy(ScanWithAquaStage, global: true) + _ * new ScanWithAquaStage(_, _, _) >> { Object[] args -> + capturedCfg = (Map) args[2] + return Stub(ScanWithAquaStage) { + execute() >> null + run() >> null + } + } + + when: + def script = loadScript('vars/odsComponentStageScanWithAqua.groovy') + script.call( + context, + [resourceName: 'my-image', branches: ['master', 'release/']] + ) + + then: + capturedCfg != null + capturedCfg.resourceName == 'my-image' + capturedCfg.branches == ['master', 'release/'] + assertJobStatusSuccess() + } + } diff --git a/vars/odsComponentStageScanWithAqua.groovy b/vars/odsComponentStageScanWithAqua.groovy index 1e2d2da92a..519f38622a 100644 --- a/vars/odsComponentStageScanWithAqua.groovy +++ b/vars/odsComponentStageScanWithAqua.groovy @@ -82,6 +82,9 @@ def call(IContext context, Map config = [:]) { if (config.resourceName) { inheritedConfig.resourceName = config.resourceName } + if (config.branches) { + inheritedConfig.branches = config.branches + } if (enabledInCluster && enabledInProject) { new ScanWithAquaStage(this, context,