diff --git a/documentation/docs/steps/transportRequestReqIDFromGit.md b/documentation/docs/steps/transportRequestReqIDFromGit.md index 78afb7846..b0b776dc3 100644 --- a/documentation/docs/steps/transportRequestReqIDFromGit.md +++ b/documentation/docs/steps/transportRequestReqIDFromGit.md @@ -14,6 +14,18 @@ See [transportRequestUploadSOLMAN](transportRequestUploadSOLMAN.md). With `transportRequestReqIDFromGit` you can retrieve the transport request ID from the commit message of the Git repository of your project. This way, you can address the transport request without having to change the setup of your pipeline. Please make sure that the ID is unique in the defined search range. +## General Purpose Pipeline Init Stage + +The step can also be configured via General Purpose Pipeline in Init stage using the config.yml as follows: + +```yaml +stages: + Init: + transportRequestReqIDFromGit: true +``` + +This will initialize the step within the Init stage of the pipeline and retrieve the `transportRequestId` from the git commit history. + ### Specifying the Git Commit Message `transportRequestReqIDFromGit` searches for lines that follow a defined pattern in the Git commit messages (`git log`) of your project. diff --git a/documentation/docs/steps/transportRequestUploadCTS.md b/documentation/docs/steps/transportRequestUploadCTS.md index 8d64ef4a5..79aff6519 100644 --- a/documentation/docs/steps/transportRequestUploadCTS.md +++ b/documentation/docs/steps/transportRequestUploadCTS.md @@ -36,7 +36,7 @@ To create an own Docker image with the [SAP Fiori tools](https://help.sap.com/vi 1. Push your image to your private [Docker Hub registry](https://hub.docker.com/): ```/bin/bash - docker push my/fiori-node + docker push my/fiori-node ``` 1. Add the following content to your `config.yml` file: @@ -138,6 +138,18 @@ transportRequestReqIDFromGit( script: this ) transportRequestUploadCTS( script: this, ... ) ``` +## General Purpose Pipeline Release Stage + +The step can also be configured via General Purpose Pipeline in Release stage using the config.yml as follows: + +```groovy +stages: + Release: + transportRequestUploadCTS: true +``` + +This will initialize the step within the Release stage of the pipeline and will upload the desired application (SAPUI5/OPENUI5) to the SAPUI5 ABAP repository. + ## ${docGenParameters} ## ${docGenConfiguration} diff --git a/pkg/transportrequest/cts/upload.go b/pkg/transportrequest/cts/upload.go index 0245437cb..fb22b4260 100644 --- a/pkg/transportrequest/cts/upload.go +++ b/pkg/transportrequest/cts/upload.go @@ -101,7 +101,7 @@ func (action *UploadAction) Perform(command command.ShellRunner) error { fmt.Sprintf("%s=%s", abapPasswordKey, action.Connection.Password), }) - cmd := []string{"#!/bin/bash -e"} + cmd := []string{"#!/bin/sh -e"} noInstall := len(action.Node.DeployDependencies) == 0 if !noInstall { @@ -119,7 +119,7 @@ func (action *UploadAction) Perform(command command.ShellRunner) error { cmd = append(cmd, deployStatement) - return command.RunShell("/bin/bash", strings.Join(cmd, "\n")) + return command.RunShell("/bin/sh", strings.Join(cmd, "\n")) } func getPrepareFioriEnvironmentStatement(deps []string, npmInstallOpts []string) string { diff --git a/test/groovy/templates/PiperPipelineStageInitTest.groovy b/test/groovy/templates/PiperPipelineStageInitTest.groovy index a226f13bc..790742e0c 100644 --- a/test/groovy/templates/PiperPipelineStageInitTest.groovy +++ b/test/groovy/templates/PiperPipelineStageInitTest.groovy @@ -97,6 +97,10 @@ class PiperPipelineStageInitTest extends BasePiperTest { helper.registerAllowedMethod('slackSendNotification', [Map.class], {m -> stepsCalled.add('slackSendNotification') }) + + helper.registerAllowedMethod('transportRequestReqIDFromGit', [Map.class], {m -> + stepsCalled.add('transportRequestReqIDFromGit') + }) } @Test @@ -126,7 +130,6 @@ class PiperPipelineStageInitTest extends BasePiperTest { @Test void testInitDefault() { - jsr.step.piperPipelineStageInit( script: nullScript, juStabUtils: utils, @@ -139,6 +142,30 @@ class PiperPipelineStageInitTest extends BasePiperTest { assertThat(nullScript.commonPipelineEnvironment.configuration.stageStashes.Init.unstash, is([])) } + @Test + void testTransportRequestReqIDFromGitIfFalse() { + jsr.step.piperPipelineStageInit( + script: nullScript, + juStabUtils: utils, + buildTool: 'maven', + stashSettings: 'com.sap.piper/pipeline/stashSettings.yml', + transportRequestReqIDFromGit: false + ) + assertThat(stepsCalled, not(hasItem('transportRequestReqIDFromGit'))) + } + + @Test + void testTransportRequestReqIDFromGitIfTrue() { + jsr.step.piperPipelineStageInit( + script: nullScript, + juStabUtils: utils, + buildTool: 'maven', + stashSettings: 'com.sap.piper/pipeline/stashSettings.yml', + transportRequestReqIDFromGit: true + ) + assertThat(stepsCalled, hasItem( 'transportRequestReqIDFromGit')) + } + @Test void testCustomStashSettings() { jryr.registerYaml('customStashSettings.yml',"Init: \n unstash: source") diff --git a/test/groovy/templates/PiperPipelineStageReleaseTest.groovy b/test/groovy/templates/PiperPipelineStageReleaseTest.groovy index 9c53c233c..68c1b9768 100644 --- a/test/groovy/templates/PiperPipelineStageReleaseTest.groovy +++ b/test/groovy/templates/PiperPipelineStageReleaseTest.groovy @@ -72,6 +72,11 @@ class PiperPipelineStageReleaseTest extends BasePiperTest { stepsCalled.add('githubPublishRelease') stepParameters.githubPublishRelease = m }) + + helper.registerAllowedMethod('transportRequestUploadCTS', [Map.class], {m -> + stepsCalled.add('transportRequestUploadCTS') + stepParameters.transportRequestUploadCTS = m + }) } @Test @@ -81,7 +86,7 @@ class PiperPipelineStageReleaseTest extends BasePiperTest { script: nullScript, juStabUtils: utils ) - assertThat(stepsCalled, not(anyOf(hasItem('cloudFoundryDeploy'), hasItem('neoDeploy'), hasItem('kubernetesDeploy'), hasItem('healthExecuteCheck'), hasItem('githubPublishRelease')))) + assertThat(stepsCalled, not(anyOf(hasItem('cloudFoundryDeploy'), hasItem('neoDeploy'), hasItem('kubernetesDeploy'), hasItem('healthExecuteCheck'), hasItem('githubPublishRelease'), hasItem('transportRequestUploadCTS')))) } @Test @@ -158,4 +163,28 @@ class PiperPipelineStageReleaseTest extends BasePiperTest { assertThat(stepsCalled, hasItem('githubPublishRelease')) } + + @Test + void testReleaseStageTransportRequestUploadCTS() { + + jsr.step.piperPipelineStageRelease( + script: nullScript, + juStabUtils: utils, + transportRequestUploadCTS: true + ) + + assertThat(stepsCalled, hasItem('transportRequestUploadCTS')) + } + + @Test + void testReleaseStageTransportRequestUploadCTSWhenSetToFalse() { + + jsr.step.piperPipelineStageRelease( + script: nullScript, + juStabUtils: utils, + transportRequestUploadCTS: false + ) + + assertThat(stepsCalled, not(hasItem('transportRequestUploadCTS'))) + } } diff --git a/vars/piperPipelineStageInit.groovy b/vars/piperPipelineStageInit.groovy index 6bd92d786..92d5a7e96 100644 --- a/vars/piperPipelineStageInit.groovy +++ b/vars/piperPipelineStageInit.groovy @@ -70,7 +70,12 @@ import static com.sap.piper.Prerequisites.checkScript * Sets the build version. * @possibleValues `true`, `false` */ - 'artifactPrepareVersion' + 'artifactPrepareVersion', + /** + * Retrieve transport request from git commit history. + * @possibleValues `true`, `false` + */ + 'transportRequestReqIDFromGit' ] @Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus(STAGE_STEP_KEYS) @Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS.plus([ @@ -124,7 +129,6 @@ import static com.sap.piper.Prerequisites.checkScript */ @GenerateStageDocumentation(defaultStageName = 'Init') void call(Map parameters = [:]) { - def script = checkScript(this, parameters) ?: this def utils = parameters.juStabUtils ?: new Utils() @@ -172,6 +176,7 @@ void call(Map parameters = [:]) { .withMandatoryProperty('buildTool') .use() + if (config.legacyConfigSettings) { Map legacyConfigSettings = readYaml(text: libraryResource(config.legacyConfigSettings)) checkForLegacyConfiguration(script: script, legacyConfigSettings: legacyConfigSettings) @@ -248,6 +253,10 @@ void call(Map parameters = [:]) { } artifactPrepareVersion prepareVersionParams } + + if (config.transportRequestReqIDFromGit) { + transportRequestReqIDFromGit(script: script) + } pipelineStashFilesBeforeBuild script: script } } diff --git a/vars/piperPipelineStageRelease.groovy b/vars/piperPipelineStageRelease.groovy index 1d6ceaa35..cdc9c0b3d 100644 --- a/vars/piperPipelineStageRelease.groovy +++ b/vars/piperPipelineStageRelease.groovy @@ -26,7 +26,9 @@ import static com.sap.piper.Prerequisites.checkScript /** Publishes release information to GitHub. */ 'githubPublishRelease', /** Executes smoke tests by running the npm script 'ci-smoke' defined in the project's package.json file. */ - 'npmExecuteEndToEndTests' + 'npmExecuteEndToEndTests', + /** This step uploads SAPUI5 application to the SAPUI5 ABAP repository. */ + 'transportRequestUploadCTS' ] @Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus(STAGE_STEP_KEYS) @Field Set PARAMETER_KEYS = STEP_CONFIG_KEYS @@ -54,6 +56,7 @@ void call(Map parameters = [:]) { .addIfEmpty('neoDeploy', script.commonPipelineEnvironment.configuration.runStep?.get(stageName)?.neoDeploy) .addIfEmpty('kubernetesDeploy', script.commonPipelineEnvironment.configuration.runStep?.get(stageName)?.kubernetesDeploy) .addIfEmpty('npmExecuteEndToEndTests', script.commonPipelineEnvironment.configuration.runStep?.get(stageName)?.npmExecuteEndToEndTests) + .addIfEmpty('transportRequestUploadCTS', script.commonPipelineEnvironment.configuration.runStep?.get(stageName)?.transportRequestUploadCTS) .use() piperStageWrapper (script: script, stageName: stageName) { @@ -106,5 +109,11 @@ void call(Map parameters = [:]) { githubPublishRelease script: script } + if (config.transportRequestUploadCTS) { + durationMeasure(script: script, measurementName: 'deploy_release_transportRequestUploadCTS_duration') { + transportRequestUploadCTS script: script + } + } + } }