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
|
# 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)
|
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
|
||||||
ifeq (,$(shell go env GOBIN))
|
ifeq (,$(shell go env GOBIN))
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ metadata:
|
|||||||
name: cleanup-job
|
name: cleanup-job
|
||||||
spec:
|
spec:
|
||||||
gitlabSecretRef: gitlab-credentials
|
gitlabSecretRef: gitlab-credentials
|
||||||
repositoryURL: mygroup/myrepo
|
repositoryURL: https://gitlab.example.com/mygroup/myrepo.git
|
||||||
branch: main
|
branch: main
|
||||||
scriptPath: scripts/cleanup.sh
|
scriptPath: scripts/cleanup.sh
|
||||||
serviceAccountName: backup-sa
|
serviceAccountName: backup-sa
|
||||||
@@ -97,7 +97,7 @@ metadata:
|
|||||||
spec:
|
spec:
|
||||||
schedule: "0 2 * * *"
|
schedule: "0 2 * * *"
|
||||||
gitlabSecretRef: gitlab-credentials
|
gitlabSecretRef: gitlab-credentials
|
||||||
repositoryURL: mygroup/myrepo
|
repositoryURL: https://gitlab.example.com/mygroup/myrepo.git
|
||||||
branch: main
|
branch: main
|
||||||
scriptPath: scripts/backup.sh
|
scriptPath: scripts/backup.sh
|
||||||
serviceAccountName: backup-sa
|
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 |
|
| `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 |
|
| `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") |
|
| `branch` | string | No | Git branch to checkout (default: "main") |
|
||||||
| `scriptPath` | string | Yes | Relative path to script in repository |
|
| `scriptPath` | string | Yes | Relative path to script in repository |
|
||||||
| `image` | string | No | Container image for git clone (default: "bitnami/git:latest") |
|
| `image` | string | No | Container image for git clone (default: "bitnami/git:latest") |
|
||||||
|
|||||||
@@ -34,7 +34,9 @@ type GitlabJobRunnerSpec struct {
|
|||||||
// +required
|
// +required
|
||||||
GitlabSecretRef string `json:"gitlabSecretRef"`
|
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
|
// +required
|
||||||
RepositoryURL string `json:"repositoryURL"`
|
RepositoryURL string `json:"repositoryURL"`
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,10 @@ spec:
|
|||||||
description: image is the container image to use for execution
|
description: image is the container image to use for execution
|
||||||
type: string
|
type: string
|
||||||
repositoryURL:
|
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
|
type: string
|
||||||
schedule:
|
schedule:
|
||||||
description: schedule in Cron format for recurring execution. If empty,
|
description: schedule in Cron format for recurring execution. If empty,
|
||||||
|
|||||||
@@ -4,5 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
|
|||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
images:
|
images:
|
||||||
- name: controller
|
- name: controller
|
||||||
newName: controller
|
newName: git.realmanual.ru/pub/gitlab-job-runner
|
||||||
newTag: latest
|
newTag: latest
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ metadata:
|
|||||||
name: gitlabjobrunner-sample-job
|
name: gitlabjobrunner-sample-job
|
||||||
spec:
|
spec:
|
||||||
gitlabSecretRef: gitlab-credentials
|
gitlabSecretRef: gitlab-credentials
|
||||||
repositoryURL: mygroup/myrepo
|
repositoryURL: https://gitlab.example.com/mygroup/myrepo.git
|
||||||
branch: main
|
branch: main
|
||||||
scriptPath: scripts/cleanup.sh
|
scriptPath: scripts/cleanup.sh
|
||||||
image: bitnami/git:latest
|
image: bitnami/git:latest
|
||||||
@@ -25,7 +25,7 @@ metadata:
|
|||||||
spec:
|
spec:
|
||||||
schedule: "0 2 * * *"
|
schedule: "0 2 * * *"
|
||||||
gitlabSecretRef: gitlab-credentials
|
gitlabSecretRef: gitlab-credentials
|
||||||
repositoryURL: mygroup/myrepo
|
repositoryURL: https://gitlab.example.com/mygroup/myrepo.git
|
||||||
branch: main
|
branch: main
|
||||||
scriptPath: scripts/backup.sh
|
scriptPath: scripts/backup.sh
|
||||||
image: bitnami/git:latest
|
image: bitnami/git:latest
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ metadata:
|
|||||||
name: example-job
|
name: example-job
|
||||||
spec:
|
spec:
|
||||||
gitlabSecretRef: gitlab-credentials
|
gitlabSecretRef: gitlab-credentials
|
||||||
repositoryURL: mygroup/myrepo
|
repositoryURL: https://gitlab.example.com/mygroup/myrepo.git
|
||||||
branch: main
|
branch: main
|
||||||
scriptPath: scripts/deploy.sh
|
scriptPath: scripts/deploy.sh
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ replicaCount: 1
|
|||||||
|
|
||||||
image:
|
image:
|
||||||
repository: git.realmanual.ru/pub/gitlab-job-runner
|
repository: git.realmanual.ru/pub/gitlab-job-runner
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: Always #IfNotPresent
|
||||||
tag: "latest"
|
tag: "latest"
|
||||||
|
|
||||||
imagePullSecrets: []
|
imagePullSecrets: []
|
||||||
|
|||||||
@@ -310,8 +310,15 @@ func (r *GitlabJobRunnerReconciler) constructPodSpec(runner *batchv1alpha1.Gitla
|
|||||||
"sh",
|
"sh",
|
||||||
"-c",
|
"-c",
|
||||||
fmt.Sprintf(`
|
fmt.Sprintf(`
|
||||||
git clone -b %s --depth 1 https://oauth2:$GITLAB_TOKEN@$(echo $GITLAB_URL | sed 's|https://||')/%s /workspace
|
REPO_URL="%s"
|
||||||
`, branch, runner.Spec.RepositoryURL),
|
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{
|
Env: []corev1.EnvVar{
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user