From 22047c685a97fa83010ca36dfe69b72f25274df9 Mon Sep 17 00:00:00 2001 From: William Petit Date: Tue, 24 Mar 2020 10:00:48 +0100 Subject: [PATCH] Fix cpkg skipCi/skipPush options handling --- vars/cpkg.groovy | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/vars/cpkg.groovy b/vars/cpkg.groovy index 3fd8567..5469715 100644 --- a/vars/cpkg.groovy +++ b/vars/cpkg.groovy @@ -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,36 +84,8 @@ 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}"]) { - proc.call() - } - } finally { - sh(script: "rm -f '${tmpAskPassScript}'") - } - + git.withHTTPCredentials(gitCredentials) { + proc.call() } } else { proc.call()