git oauth
All checks were successful
docker-build / Build image (push) Successful in 39s

This commit is contained in:
2025-12-07 20:52:14 +07:00
parent 16639c6cd5
commit cdfcdac23f

View File

@@ -310,13 +310,20 @@ func (r *GitlabJobRunnerReconciler) constructPodSpec(runner *batchv1alpha1.Gitla
"sh", "sh",
"-c", "-c",
fmt.Sprintf(` fmt.Sprintf(`
set -e
REPO_URL="%s" REPO_URL="%s"
# Configure git credential helper
git config --global credential.helper store
echo "https://$GITLAB_TOKEN:x-oauth-basic@$(echo $GITLAB_URL | sed 's|https://||' | sed 's|/||')" > ~/.git-credentials
if echo "$REPO_URL" | grep -q '^https://'; then if echo "$REPO_URL" | grep -q '^https://'; then
# Full URL provided - use it directly with token injection # Full URL provided
git clone -b %s --depth 1 $(echo $REPO_URL | sed "s|https://|https://oauth2:$GITLAB_TOKEN@|") /workspace git clone -b %s --depth 1 "$REPO_URL" /workspace
else else
# Relative path - construct URL from GITLAB_URL # Relative path - construct URL from GITLAB_URL
git clone -b %s --depth 1 https://oauth2:$GITLAB_TOKEN@$(echo $GITLAB_URL | sed 's|https://||')/$REPO_URL /workspace CLEAN_URL=$(echo $GITLAB_URL | sed 's|/$||')
git clone -b %s --depth 1 "$CLEAN_URL/$REPO_URL" /workspace
fi fi
`, runner.Spec.RepositoryURL, branch, branch), `, runner.Spec.RepositoryURL, branch, branch),
}, },