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

more precise param handover (gitUrl) in piperPipelineStageInit (#848)

Before: complete scmInfo was handed over via method signature.

After: Only the relevant part (GIT_URL from scmInfo) is handed over.

All the other properties from scmInfo are not used in the method body.
With this appraoch it is more obvious what is used inside the method.
This commit is contained in:
Marcus Holl 2019-08-20 09:08:42 +02:00 committed by GitHub
parent f69eac6f5f
commit 8c966e41c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 5 deletions

View File

@ -149,7 +149,7 @@ class PiperPipelineStageInitTest extends BasePiperTest {
]
scmInfoTestList.each {scmInfoTest ->
jsr.step.piperPipelineStageInit.setScmInfoOnCommonPipelineEnvironment(nullScript, scmInfoTest)
jsr.step.piperPipelineStageInit.setGitUrlsOnCommonPipelineEnvironment(nullScript, scmInfoTest.GIT_URL)
assertThat(nullScript.commonPipelineEnvironment.getGitSshUrl(), is(scmInfoTest.expectedSsh))
assertThat(nullScript.commonPipelineEnvironment.getGitHttpsUrl(), is(scmInfoTest.expectedHttp))
assertThat(nullScript.commonPipelineEnvironment.getGithubOrg(), is(scmInfoTest.expectedOrg))

View File

@ -63,7 +63,7 @@ void call(Map parameters = [:]) {
//perform stashing based on libray resource piper-stash-settings.yml if not configured otherwise
initStashConfiguration(script, config)
setScmInfoOnCommonPipelineEnvironment(script, scmInfo)
setGitUrlsOnCommonPipelineEnvironment(script, scmInfo.GIT_URL)
script.commonPipelineEnvironment.setGitCommitId(scmInfo.GIT_COMMIT)
if (config.verbose) {
@ -131,9 +131,7 @@ private void initStashConfiguration (script, config) {
script.commonPipelineEnvironment.configuration.stageStashes = stashConfiguration
}
private void setScmInfoOnCommonPipelineEnvironment(script, scmInfo) {
def gitUrl = scmInfo.GIT_URL
private void setGitUrlsOnCommonPipelineEnvironment(script, String gitUrl) {
def gitPath = ''
if (gitUrl.startsWith('http')) {