1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-20 05:19:40 +02:00

helmExecute triggered by buildExecute (#4521)

This commit is contained in:
Marcus Holl 2023-08-21 11:10:00 +02:00 committed by GitHub
parent 47f4b1e42d
commit d6d3b6b091
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 2 deletions

View File

@ -271,7 +271,7 @@ func helmExecuteMetadata() config.StepData {
{
Name: "chartPath",
ResourceRef: []config.ResourceReference{},
Scope: []string{"PARAMETERS", "STAGES", "STEPS"},
Scope: []string{"GENERAL", "PARAMETERS", "STAGES", "STEPS"},
Type: "string",
Mandatory: false,
Aliases: []config.Alias{{Name: "helmChartPath"}},

View File

@ -58,6 +58,7 @@ spec:
type: string
description: Defines the chart path for helm. chartPath is mandatory for install/upgrade/publish commands.
scope:
- GENERAL
- PARAMETERS
- STAGES
- STEPS

View File

@ -314,4 +314,41 @@ class BuildExecuteTest extends BasePiperTest {
)
assertThat(buildToolCalled, is(true))
}
@Test
void testHelmExecuteCalledWhenConfigured() {
def helmExecuteCalled = false
helper.registerAllowedMethod('helmExecute', [Map.class], { m ->
helmExecuteCalled = true
return
})
helper.registerAllowedMethod('npmExecuteScripts', [Map.class], { m ->
})
stepRule.step.buildExecute(
script: nullScript,
buildTool: 'npm',
helmExecute: true
)
assertThat(helmExecuteCalled, is(true))
}
@Test
void testHelmExecuteNotCalledWhenNotConfigured() {
def helmExecuteCalled = false
helper.registerAllowedMethod('helmExecute', [Map.class], { m ->
helmExecuteCalled = true
return
})
helper.registerAllowedMethod('npmExecuteScripts', [Map.class], { m ->
})
stepRule.step.buildExecute(
script: nullScript,
buildTool: 'npm',
helmExecute: false
)
assertThat(helmExecuteCalled, is(false))
}
}

View File

@ -32,7 +32,9 @@ import static com.sap.piper.Prerequisites.checkScript
/** For buildTool npm: Execute npm install (boolean, default 'true') */
'npmInstall',
/** For buildTool npm: List of npm run scripts to execute */
'npmRunScripts'
'npmRunScripts',
/** toggles if a helmExecute is triggered at end of the step after invoking the build tool */
'helmExecute'
])
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
@ -100,5 +102,9 @@ void call(Map parameters = [:]) {
error "[${STEP_NAME}] buildTool not set and no dockerImage & dockerCommand provided."
}
}
if(config.helmExecute) {
helmExecute script: script
}
}
}