diff --git a/base/scripts/onyxia-init.sh b/base/scripts/onyxia-init.sh index 3fa7f576..414c6333 100755 --- a/base/scripts/onyxia-init.sh +++ b/base/scripts/onyxia-init.sh @@ -92,11 +92,14 @@ if command -v git &>/dev/null; then fi if [[ -n "$GIT_REPOSITORY" ]]; then if [[ -n "$GIT_PERSONAL_ACCESS_TOKEN" ]]; then - REPO_DOMAIN=`echo "$GIT_REPOSITORY" | awk -F/ '{print $3}'` - if [ $REPO_DOMAIN = "github.com" ]; then - GIT_REPOSITORY=`echo $GIT_REPOSITORY | sed "s/$REPO_DOMAIN/$GIT_PERSONAL_ACCESS_TOKEN@$REPO_DOMAIN/"` + REPO_DOMAIN=$(echo "$GIT_REPOSITORY" | awk -F/ '{print $3}') + if [ "$REPO_DOMAIN" = "github.com" ]; then + GIT_REPOSITORY=$(echo "$GIT_REPOSITORY" | sed "s|$REPO_DOMAIN|$GIT_PERSONAL_ACCESS_TOKEN@$REPO_DOMAIN|") + GIT_REPOSITORY=$(echo "$GIT_REPOSITORY" | sed "s|$REPO_DOMAIN|$GIT_PERSONAL_ACCESS_TOKEN@$REPO_DOMAIN|") + elif echo "$GIT_REPOSITORY" | grep -qi "bitbucket"; then + GIT_REPOSITORY=$(echo "$GIT_REPOSITORY" | sed "s|$REPO_DOMAIN|$GIT_USER_NAME:$GIT_PERSONAL_ACCESS_TOKEN@$REPO_DOMAIN|") else - GIT_REPOSITORY=`echo $GIT_REPOSITORY | sed "s/$REPO_DOMAIN/oauth2:$GIT_PERSONAL_ACCESS_TOKEN@$REPO_DOMAIN/"` + GIT_REPOSITORY=$(echo "$GIT_REPOSITORY" | sed "s|$REPO_DOMAIN|oauth2:$GIT_PERSONAL_ACCESS_TOKEN@$REPO_DOMAIN|") fi fi