Skip to content

Pipeline fails if defined deploy token does not already exist #1

@GitBytes

Description

@GitBytes

@kfox1111 I think there is a "chicken and egg" issue to work out here. This block seems to fail if the secret doesn't already exist:

Current Code

gitlab-lib/gitlab-lib.yaml

Lines 123 to 124 in 9db5170

SECRET_NAME="${SECRET_NAME:-gitlab-registry-token}"
kubectl get secret "$SECRET_NAME" || kubectl create secret docker-registry "$SECRET_NAME" --docker-server="$CI_REGISTRY" --docker-username="$CI_DEPLOY_USER" --docker-password="$CI_DEPLOY_PASSWORD" --docker-email=gitab@blackhole.com

Current Output

$ SECRET_NAME="${SECRET_NAME:-gitlab-registry-token}" # collapsed multi-line command
Error from server (NotFound): secrets "config-editor-deploy-token" not found
error: flag docker-username is required
See 'kubectl create secret docker-registry -h' for help and examples

Proposed Solution

I would propose something more like:

    script:
    - |
      SECRET_NAME="${SECRET_NAME:-gitlab-registry-token}"
      kubectl create secret docker-registry "$SECRET_NAME" --docker-server="$CI_REGISTRY" --docker-username="$CI_DEPLOY_USER" --docker-password="$CI_DEPLOY_PASSWORD" --docker-email=gitab@blackhole.com  --dry-run -o yaml | kubectl apply -f -

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions