Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
37 changes: 37 additions & 0 deletions test/groovy/vars/OdsComponentStageScanWithAquaSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

}
3 changes: 3 additions & 0 deletions vars/odsComponentStageScanWithAqua.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down