Skip to content

Commit d6d3b6b

Browse files
authored
helmExecute triggered by buildExecute (#4521)
1 parent 47f4b1e commit d6d3b6b

File tree

4 files changed

+46
-2
lines changed

4 files changed

+46
-2
lines changed

cmd/helmExecute_generated.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/metadata/helmExecute.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ spec:
5858
type: string
5959
description: Defines the chart path for helm. chartPath is mandatory for install/upgrade/publish commands.
6060
scope:
61+
- GENERAL
6162
- PARAMETERS
6263
- STAGES
6364
- STEPS

test/groovy/BuildExecuteTest.groovy

+37
Original file line numberDiff line numberDiff line change
@@ -314,4 +314,41 @@ class BuildExecuteTest extends BasePiperTest {
314314
)
315315
assertThat(buildToolCalled, is(true))
316316
}
317+
318+
@Test
319+
void testHelmExecuteCalledWhenConfigured() {
320+
def helmExecuteCalled = false
321+
helper.registerAllowedMethod('helmExecute', [Map.class], { m ->
322+
helmExecuteCalled = true
323+
return
324+
})
325+
helper.registerAllowedMethod('npmExecuteScripts', [Map.class], { m ->
326+
})
327+
328+
stepRule.step.buildExecute(
329+
script: nullScript,
330+
buildTool: 'npm',
331+
helmExecute: true
332+
)
333+
334+
assertThat(helmExecuteCalled, is(true))
335+
}
336+
337+
@Test
338+
void testHelmExecuteNotCalledWhenNotConfigured() {
339+
def helmExecuteCalled = false
340+
helper.registerAllowedMethod('helmExecute', [Map.class], { m ->
341+
helmExecuteCalled = true
342+
return
343+
})
344+
helper.registerAllowedMethod('npmExecuteScripts', [Map.class], { m ->
345+
})
346+
stepRule.step.buildExecute(
347+
script: nullScript,
348+
buildTool: 'npm',
349+
helmExecute: false
350+
)
351+
352+
assertThat(helmExecuteCalled, is(false))
353+
}
317354
}

vars/buildExecute.groovy

+7-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ import static com.sap.piper.Prerequisites.checkScript
3232
/** For buildTool npm: Execute npm install (boolean, default 'true') */
3333
'npmInstall',
3434
/** For buildTool npm: List of npm run scripts to execute */
35-
'npmRunScripts'
35+
'npmRunScripts',
36+
/** toggles if a helmExecute is triggered at end of the step after invoking the build tool */
37+
'helmExecute'
3638
])
3739
@Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS
3840

@@ -100,5 +102,9 @@ void call(Map parameters = [:]) {
100102
error "[${STEP_NAME}] buildTool not set and no dockerImage & dockerCommand provided."
101103
}
102104
}
105+
106+
if(config.helmExecute) {
107+
helmExecute script: script
108+
}
103109
}
104110
}

0 commit comments

Comments
 (0)