Fix cpkg skipCi/skipPush options handling

This commit is contained in:
wpetit 2020-03-24 10:00:48 +01:00
parent 7ac2319ae1
commit 22047c685a
1 changed files with 4 additions and 32 deletions

View File

@ -10,8 +10,8 @@ def call(Map params = [:]) {
def gitCredentials = params.gitCredentials ? params.gitCredentials : null
def gitEmail = params.gitEmail ? params.gitEmail : 'jenkins@cadoles.com'
def gitUsername = params.gitUsername ? params.gitUsername : 'Jenkins'
def skipCi = params.skipCi ? params.skipCi : false
def skipPush = params.skipPush ? params.skipPush: true
def skipCi = params.containsKey('skipCi') ? params.skipCi : false
def skipPush = params.containsKey('skipPush') ? params.skipPush: true
// Define dist branch based on provided informations and base branch name
def distBranch = "dist/${dist}/${distVersion}/${distBranchName}"
@ -84,37 +84,9 @@ def call(Map params = [:]) {
}
if (gitCredentials != null) {
withCredentials([
usernamePassword(
credentialsId: gitCredentials,
usernameVariable: 'GIT_USERNAME',
passwordVariable: 'GIT_PASSWORD'
)
]) {
def randomUUID = UUID.randomUUID().toString()
def tmpAskPassScript = pwd(tmp:true) + "/${randomUUID}"
try {
writeFile(
file: tmpAskPassScript,
text: '''
#!/bin/sh
case "$1" in
Username*) echo $GIT_USERNAME ;;
Password*) echo $GIT_PASSWORD ;;
esac
'''
)
sh(script: "git config user.email '${gitEmail}'")
sh(script: "git config user.name '${gitUsername}'")
sh(script: "chmod +x '${tmpAskPassScript}'")
withEnv(["GIT_ASKPASS=${tmpAskPassScript}"]) {
git.withHTTPCredentials(gitCredentials) {
proc.call()
}
} finally {
sh(script: "rm -f '${tmpAskPassScript}'")
}
}
} else {
proc.call()
}