From cbf168ebd86b09d06b8d7d7e559e5bcedd0607dd Mon Sep 17 00:00:00 2001 From: Tobias Poganiuch <tobias.poganiuch@seco.com> Date: Mon, 13 May 2024 13:41:38 +0200 Subject: [PATCH] build:credentials: Fix error when storing credentials in cache The credentials helper wasn't storing the credentials in the cache. Seemingly, the echo added whitespaces at the beginning of the lines which can't be interpreted by the git credential approve command. Also the USERNAME was renamed to TOKEN_USER because the variable is already filled with the system users name. --- build-pipeline.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/build-pipeline.yml b/build-pipeline.yml index 89024fe9..39d245c4 100644 --- a/build-pipeline.yml +++ b/build-pipeline.yml @@ -51,21 +51,17 @@ workflow: - git config --global --add safe.directory "*" - while read -r credentials; do TOKEN_PATH=$(echo $credentials | cut -d':' -f1); - USERNAME=$(echo $credentials | cut -d':' -f2); + TOKEN_USER=$(echo $credentials | cut -d':' -f2); TOKEN=$(echo $credentials | cut -d':' -f3); - if [ -z "${USERNAME}" ] || [ -z "${TOKEN}" ]; then + if [ -z "${TOKEN_USER}" ] || [ -z "${TOKEN}" ]; then echo "Invalid Git Credentials entry; Skipping ..."; continue; fi - echo "protocol=https\n" - "host=git.seco.com\n" - "path=${TOKEN_PATH}\n" - "username=${USERNAME}\n" - "password=${TOKEN}\n" | - git credential approve - ; + printf "protocol=https\nhost=git.seco.com\npath=%s\nusername=%s\npassword=%s\n" + "${TOKEN_PATH}" "${TOKEN_USER}" "${TOKEN}" | + git credential approve; done <<< "${GITLAB_PRIVATE_TOKEN}" .repo_checkout: &repo_checkout -- GitLab