You've already forked sap-jenkins-library
mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-11-06 09:09:19 +02:00
Add transport request to GPP (#3862)
* Add TransportRequestUploadCTS step to Release * typo comma * test transportRequest git ID * Update piperPipelineStageInit.groovy * add echo * aggressive echo * Update piperPipelineStageInit.groovy * remove echo + add unitTests * fix typos and documentation syntax * test documentation syntax * test documentation syntax * Switch to shell * Documentation changes * Add review changes * Remove echo * Refactor test cases Co-authored-by: Kondreddy <srinikitha.kondreddy@sap.com> Co-authored-by: Oliver Feldmann <oliver.feldmann@sap.com> Co-authored-by: Roland Stengel <r.stengel@sap.com>
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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')))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user