11import static com.sap.piper.Prerequisites.checkScript
2+ import static com.sap.piper.BashUtils.quoteAndEscape as q
23
34import com.sap.piper.GenerateDocumentation
45import com.sap.piper.ConfigurationHelper
@@ -175,7 +176,7 @@ void call(Map parameters = [:], Closure body = null) {
175176 def gitConfig = []
176177
177178 if (config. gitUserEMail) {
178- gitConfig. add(" -c user.email=\" ${ config.gitUserEMail} \" " )
179+ gitConfig. add(" -c user.email=${ q( config.gitUserEMail) } " )
179180 } else {
180181 // in case there is no user.email configured on project level we might still
181182 // be able to work in case there is a configuration available on plain git level.
@@ -184,7 +185,7 @@ void call(Map parameters = [:], Closure body = null) {
184185 }
185186 }
186187 if (config. gitUserName) {
187- gitConfig. add(" -c user.name=\" ${ config.gitUserName} \" " )
188+ gitConfig. add(" -c user.name=${ q( config.gitUserName) } " )
188189 } else {
189190 // in case there is no user.name configured on project level we might still
190191 // be able to work in case there is a configuration available on plain git level.
@@ -199,7 +200,7 @@ void call(Map parameters = [:], Closure body = null) {
199200 set -e
200201 git add . --update
201202 git ${ gitConfig} commit -m 'update version ${ newVersion} '
202- git tag ${ config.tagPrefix}${ newVersion} """
203+ git tag ${ q( config.tagPrefix+ newVersion) } """
203204 config. gitCommitId = gitUtils. getGitCommitIdOrNull()
204205 } catch (e) {
205206 error " [${ STEP_NAME} ]git commit and tag failed: ${ e} "
@@ -215,7 +216,7 @@ void call(Map parameters = [:], Closure body = null) {
215216 .use()
216217
217218 sshagent([config. gitSshKeyCredentialsId]) {
218- sh " git push ${ config.gitSshUrl} ${ config.tagPrefix}${ newVersion} "
219+ sh " git push ${ q( config.gitSshUrl) } ${ q( config.tagPrefix+ newVersion) } "
219220 }
220221
221222 } else if (gitPushMode == GitPushMode . HTTPS ) {
@@ -259,7 +260,7 @@ void call(Map parameters = [:], Closure body = null) {
259260 gitConfig = []
260261
261262 if (config. gitHttpProxy) {
262- gitConfig. add(" -c http.proxy=\" ${ config.gitHttpProxy} \" " )
263+ gitConfig. add(" -c http.proxy=${ q( config.gitHttpProxy) } " )
263264 }
264265
265266 if (config. gitDisableSslVerification) {
@@ -288,7 +289,7 @@ void call(Map parameters = [:], Closure body = null) {
288289 gitPushFlags = gitPushFlags. join(' ' )
289290
290291 sh script : """ |#!/bin/bash ${ hashbangFlags}
291- |${ gitDebug} git ${ gitConfig} push ${ gitPushFlags} ${ gitUrlWithCredentials} ${ config.tagPrefix}${ newVersion} ${ streamhandling} """ . stripMargin()
292+ |${ gitDebug} git ${ gitConfig} push ${ gitPushFlags} ${ gitUrlWithCredentials} ${ q( config.tagPrefix+ newVersion) } ${ streamhandling} """ . stripMargin()
292293 }
293294 } else {
294295 echo " Git push mode: ${ gitPushMode.toString()} . Git push to remote has been skipped."
@@ -313,5 +314,5 @@ def isAppContainer(config){
313314}
314315
315316def getTimestamp (pattern ){
316- return sh(returnStdout : true , script : " date --utc +' ${ pattern} ' " ). trim()
317+ return sh(returnStdout : true , script : " date --utc +${ q( pattern) } " ). trim()
317318}
0 commit comments