From 23869efe3dc43f3457bf34fea5825ea00a52570c Mon Sep 17 00:00:00 2001 From: Carles Pina i Estany Date: Wed, 15 Dec 2021 00:09:49 +0000 Subject: [PATCH] Better handling of the git clone error --- entrypoint.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index b476ded..fa38ab0 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -33,17 +33,15 @@ echo "[+] Cloning destination git repository $DESTINATION_REPOSITORY_NAME" git config --global user.email "$USER_EMAIL" git config --global user.name "$USER_NAME" -git clone --single-branch --branch "$TARGET_BRANCH" "https://$USER_NAME:$API_TOKEN_GITHUB@$GITHUB_SERVER/$DESTINATION_REPOSITORY_USERNAME/$DESTINATION_REPOSITORY_NAME.git" "$CLONE_DIR" -GIT_CLONE_EXIT_CODE=$? - -if [ "$GIT_CLONE_EXIT_CODE" != 0 ] -then - echo "::error::Could not clone the destination repository. Tried with:" +{ + git clone --single-branch --branch "$TARGET_BRANCH" "https://$USER_NAME:$API_TOKEN_GITHUB@$GITHUB_SERVER/$DESTINATION_REPOSITORY_USERNAME/$DESTINATION_REPOSITORY_NAME.git" "$CLONE_DIR" +} || { + echo "::error::Could not clone the destination repository. Command:" echo "::error::git clone --single-branch --branch $TARGET_BRANCH https://$USER_NAME:the_api_token@$GITHUB_SERVER/$DESTINATION_REPOSITORY_USERNAME/$DESTINATION_REPOSITORY_NAME.git $CLONE_DIR" echo "::error::Please verify that the branch $TARGET_BRANCH exist in the target repository and that the repository exist and is accessible by your API_TOKEN_GITHUB" exit 1 -fi +} ls -la "$CLONE_DIR" TEMP_DIR=$(mktemp -d)