add full uri any git repos
All checks were successful
docker-build / Build image (push) Successful in 43s
All checks were successful
docker-build / Build image (push) Successful in 43s
This commit is contained in:
2
Makefile
2
Makefile
@@ -1,5 +1,5 @@
|
||||
# Image URL to use all building/pushing image targets
|
||||
IMG ?= controller:latest
|
||||
IMG ?= git.realmanual.ru/pub/gitlab-job-runner:latest
|
||||
|
||||
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
|
||||
ifeq (,$(shell go env GOBIN))
|
||||
|
||||
@@ -81,7 +81,7 @@ metadata:
|
||||
name: cleanup-job
|
||||
spec:
|
||||
gitlabSecretRef: gitlab-credentials
|
||||
repositoryURL: mygroup/myrepo
|
||||
repositoryURL: https://gitlab.example.com/mygroup/myrepo.git
|
||||
branch: main
|
||||
scriptPath: scripts/cleanup.sh
|
||||
serviceAccountName: backup-sa
|
||||
@@ -97,7 +97,7 @@ metadata:
|
||||
spec:
|
||||
schedule: "0 2 * * *"
|
||||
gitlabSecretRef: gitlab-credentials
|
||||
repositoryURL: mygroup/myrepo
|
||||
repositoryURL: https://gitlab.example.com/mygroup/myrepo.git
|
||||
branch: main
|
||||
scriptPath: scripts/backup.sh
|
||||
serviceAccountName: backup-sa
|
||||
@@ -119,7 +119,7 @@ kubectl apply -f your-gitlabjobrunner.yaml
|
||||
|----------------------|---------|----------|-------------------------------------------------------------------------------|
|
||||
| `schedule` | string | No | Cron schedule for recurring jobs. If empty, runs as one-time Job |
|
||||
| `gitlabSecretRef` | string | Yes | Name of Secret containing GITLAB_URL and GITLAB_TOKEN |
|
||||
| `repositoryURL` | string | Yes | GitLab repository path (e.g., "group/project") |
|
||||
| `repositoryURL` | string | Yes | GitLab repository (full URL or relative path like "group/project") |
|
||||
| `branch` | string | No | Git branch to checkout (default: "main") |
|
||||
| `scriptPath` | string | Yes | Relative path to script in repository |
|
||||
| `image` | string | No | Container image for git clone (default: "bitnami/git:latest") |
|
||||
|
||||
@@ -34,7 +34,9 @@ type GitlabJobRunnerSpec struct {
|
||||
// +required
|
||||
GitlabSecretRef string `json:"gitlabSecretRef"`
|
||||
|
||||
// repositoryURL is the GitLab repository to clone
|
||||
// repositoryURL is the GitLab repository URL (full URL or relative path like "group/project")
|
||||
// Full URL: https://gitlab.example.com/group/project.git
|
||||
// Relative path: group/project (requires GITLAB_URL in secret)
|
||||
// +required
|
||||
RepositoryURL string `json:"repositoryURL"`
|
||||
|
||||
|
||||
@@ -55,7 +55,10 @@ spec:
|
||||
description: image is the container image to use for execution
|
||||
type: string
|
||||
repositoryURL:
|
||||
description: repositoryURL is the GitLab repository to clone
|
||||
description: |-
|
||||
repositoryURL is the GitLab repository URL (full URL or relative path like "group/project")
|
||||
Full URL: https://gitlab.example.com/group/project.git
|
||||
Relative path: group/project (requires GITLAB_URL in secret)
|
||||
type: string
|
||||
schedule:
|
||||
description: schedule in Cron format for recurring execution. If empty,
|
||||
|
||||
@@ -4,5 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
images:
|
||||
- name: controller
|
||||
newName: controller
|
||||
newName: git.realmanual.ru/pub/gitlab-job-runner
|
||||
newTag: latest
|
||||
|
||||
@@ -8,7 +8,7 @@ metadata:
|
||||
name: gitlabjobrunner-sample-job
|
||||
spec:
|
||||
gitlabSecretRef: gitlab-credentials
|
||||
repositoryURL: mygroup/myrepo
|
||||
repositoryURL: https://gitlab.example.com/mygroup/myrepo.git
|
||||
branch: main
|
||||
scriptPath: scripts/cleanup.sh
|
||||
image: bitnami/git:latest
|
||||
@@ -25,7 +25,7 @@ metadata:
|
||||
spec:
|
||||
schedule: "0 2 * * *"
|
||||
gitlabSecretRef: gitlab-credentials
|
||||
repositoryURL: mygroup/myrepo
|
||||
repositoryURL: https://gitlab.example.com/mygroup/myrepo.git
|
||||
branch: main
|
||||
scriptPath: scripts/backup.sh
|
||||
image: bitnami/git:latest
|
||||
|
||||
@@ -124,7 +124,7 @@ metadata:
|
||||
name: example-job
|
||||
spec:
|
||||
gitlabSecretRef: gitlab-credentials
|
||||
repositoryURL: mygroup/myrepo
|
||||
repositoryURL: https://gitlab.example.com/mygroup/myrepo.git
|
||||
branch: main
|
||||
scriptPath: scripts/deploy.sh
|
||||
```
|
||||
|
||||
@@ -2,7 +2,7 @@ replicaCount: 1
|
||||
|
||||
image:
|
||||
repository: git.realmanual.ru/pub/gitlab-job-runner
|
||||
pullPolicy: IfNotPresent
|
||||
pullPolicy: Always #IfNotPresent
|
||||
tag: "latest"
|
||||
|
||||
imagePullSecrets: []
|
||||
|
||||
@@ -310,8 +310,15 @@ func (r *GitlabJobRunnerReconciler) constructPodSpec(runner *batchv1alpha1.Gitla
|
||||
"sh",
|
||||
"-c",
|
||||
fmt.Sprintf(`
|
||||
git clone -b %s --depth 1 https://oauth2:$GITLAB_TOKEN@$(echo $GITLAB_URL | sed 's|https://||')/%s /workspace
|
||||
`, branch, runner.Spec.RepositoryURL),
|
||||
REPO_URL="%s"
|
||||
if echo "$REPO_URL" | grep -q '^https://'; then
|
||||
# Full URL provided - use it directly with token injection
|
||||
git clone -b %s --depth 1 $(echo $REPO_URL | sed "s|https://|https://oauth2:$GITLAB_TOKEN@|") /workspace
|
||||
else
|
||||
# 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
|
||||
fi
|
||||
`, runner.Spec.RepositoryURL, branch, branch),
|
||||
},
|
||||
Env: []corev1.EnvVar{
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user