Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use --useV1 for checkIfStepActive #4821

Closed
wants to merge 12 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ class abapEnvironmentPipelineStageInitTest extends BasePiperTest {
activeStages.add(m)
})
shellCallRule.setReturnValue('[ -x ./piper ]', 1)
shellCallRule.setReturnValue('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --useV1 --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _', 0)
shellCallRule.setReturnValue('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _', 0)
nullScript.prepareDefaultValues(script: nullScript)
}

@Test
void testStageConfigurationToggleFalse() {
jsr.step.abapEnvironmentPipelineStageInit(script: nullScript, skipCheckout: false, piperGoUtils: piperGoUtils)
assertThat(stepsCalled, hasItems('setupCommonPipelineEnvironment', 'checkout'))
assertThat(shellCallRule.shell, hasItem('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --useV1 --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _'))
assertThat(shellCallRule.shell, hasItem('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _'))

}

Expand All @@ -93,15 +93,15 @@ class abapEnvironmentPipelineStageInitTest extends BasePiperTest {
)
assertThat(stepsCalled, not(hasItems('checkout')))
assertThat(stepsCalled, hasItems('setupCommonPipelineEnvironment'))
assertThat(shellCallRule.shell, hasItem('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --useV1 --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _'))
assertThat(shellCallRule.shell, hasItem('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _'))

}

@Test
void testSkipCheckoutToggleNull() {
jsr.step.abapEnvironmentPipelineStageInit(script: nullScript, skipCheckout: null, piperGoUtils: piperGoUtils)
assertThat(stepsCalled, hasItems('setupCommonPipelineEnvironment', 'checkout'))
assertThat(shellCallRule.shell, hasItem('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --useV1 --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _'))
assertThat(shellCallRule.shell, hasItem('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _'))
}

@Test
Expand Down
22 changes: 11 additions & 11 deletions test/groovy/templates/PiperInitRunStageConfigurationTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class PiperInitRunStageConfigurationTest extends BasePiperTest {

@Test
void testVerboseOption() {
shellCallRule.setReturnValue('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --useV1 --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _', 0)
shellCallRule.setReturnValue('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _', 0)
helper.registerAllowedMethod("readJSON", [Map.class], { m ->
if (m.containsValue(".pipeline/stage_out.json")) {
return ["testStage1":false]
Expand Down Expand Up @@ -84,12 +84,12 @@ class PiperInitRunStageConfigurationTest extends BasePiperTest {
containsString('[piperInitRunStageConfiguration] Debug - Run Stage Configuration:'),
containsString('[piperInitRunStageConfiguration] Debug - Run Step Configuration:')
))
assertThat(shellCallRule.shell, hasItem('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --useV1 --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _'))
assertThat(shellCallRule.shell, hasItem('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _'))
}

@Test(expected = Exception.class)
void testPiperShFailed() {
shellCallRule.setReturnValue('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --useV1 --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _', 1)
shellCallRule.setReturnValue('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _', 1)
helper.registerAllowedMethod("readJSON", [Map.class], { m ->
if (m.containsValue(".pipeline/stage_out.json")) {
return ["Integration":true, "Acceptance":true]
Expand All @@ -114,7 +114,7 @@ class PiperInitRunStageConfigurationTest extends BasePiperTest {
@Test
void testPiperInitDefault() {

shellCallRule.setReturnValue('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --useV1 --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _', 0)
shellCallRule.setReturnValue('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _', 0)

helper.registerAllowedMethod("readJSON", [Map.class], { m ->
if (m.containsValue(".pipeline/stage_out.json")) {
Expand Down Expand Up @@ -148,13 +148,13 @@ class PiperInitRunStageConfigurationTest extends BasePiperTest {

assertThat(nullScript.commonPipelineEnvironment.configuration.runStage.Acceptance, is(true))
assertThat(nullScript.commonPipelineEnvironment.configuration.runStage.Integration, is(true))
assertThat(shellCallRule.shell, hasItem('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --useV1 --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _'))
assertThat(shellCallRule.shell, hasItem('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _'))

}

@Test
void testConditionOnlyProductiveBranchOnNonProductiveBranch() {
shellCallRule.setReturnValue('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --useV1 --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _', 0)
shellCallRule.setReturnValue('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _', 0)
helper.registerAllowedMethod("readJSON", [Map.class], { m ->
if (m.containsValue(".pipeline/stage_out.json")) {
return ["testStage1":true]
Expand Down Expand Up @@ -200,7 +200,7 @@ stages:
)

assertThat(nullScript.commonPipelineEnvironment.configuration.runStage.testStage1, is(false))
assertThat(shellCallRule.shell, hasItem('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --useV1 --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _'))
assertThat(shellCallRule.shell, hasItem('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _'))
}

@Test
Expand All @@ -215,7 +215,7 @@ stages:
return [:]
}
})
shellCallRule.setReturnValue('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --useV1 --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _', 0)
shellCallRule.setReturnValue('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _', 0)

helper.registerAllowedMethod('libraryResource', [String.class], {s ->
if(s == 'testDefault.yml') {
Expand Down Expand Up @@ -251,12 +251,12 @@ stages:
)

assertThat(nullScript.commonPipelineEnvironment.configuration.runStage.testStage1, is(true))
assertThat(shellCallRule.shell, hasItem('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --useV1 --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _'))
assertThat(shellCallRule.shell, hasItem('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _'))
}

@Test
void testStageExtensionExists() {
shellCallRule.setReturnValue('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --useV1 --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _', 0)
shellCallRule.setReturnValue('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _', 0)
helper.registerAllowedMethod("readJSON", [Map.class], { m ->
if (m.containsValue(".pipeline/stage_out.json")) {
return ["testStage1":false, "testStage2":false, "testStage3":false, "testStage4":false, "testStage5":false]
Expand Down Expand Up @@ -330,6 +330,6 @@ steps: {}
assertThat(nullScript.commonPipelineEnvironment.configuration.runStage.testStage3, is(false))
assertThat(nullScript.commonPipelineEnvironment.configuration.runStage.testStage4, is(false))
assertThat(nullScript.commonPipelineEnvironment.configuration.runStage.testStage5, is(false))
assertThat(shellCallRule.shell, hasItem('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --useV1 --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _'))
assertThat(shellCallRule.shell, hasItem('./piper checkIfStepActive --stageConfig .pipeline/stage_conditions.yaml --stageOutputFile .pipeline/stage_out.json --stepOutputFile .pipeline/step_out.json --stage _ --step _'))
}
}
2 changes: 1 addition & 1 deletion vars/piperExecuteBin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ void handleErrorDetails(String stepName, Closure body) {
static boolean checkIfStepActive(Map parameters = [:], Script script, String piperGoPath, String stageConfig = "", String stepOutputFile = "", String stageOutputFile = "", String stage = "", String step = "") {
def utils = parameters.juStabUtils ?: new Utils()
def piperGoUtils = parameters.piperGoUtils ?: new PiperGoUtils(script, utils)
def flags = "--stageConfig ${stageConfig} --useV1"
def flags = "--stageConfig ${stageConfig}"
if (stageOutputFile) {
flags += " --stageOutputFile ${stageOutputFile}"
}
Expand Down
Loading