Skip to content

Revert "Merge branch 'ajwalker/refactor-build-settings' into 'main'"

Stan Hu requested to merge revert-f81241bc into main

What does this MR do?

This reverts !4611 (merged) because DOCKER_AUTH_CONFIG no longer works properly when it is a File CI/CD variable.

Why was this MR needed?

Previously Build.GetDockerAuthConfig() returned the JSON contents of DOCKER_AUTH_CONFIG, even if it were a File CI/CD variable. This allowed the Docker client to work. In 16.9.0, we had this change:

func (b *Build) GetDockerAuthConfig() string {
-	return b.GetAllVariables().Value("DOCKER_AUTH_CONFIG")
+	return b.Settings().DockerAuthConfig
// Value is similar to Get(), but always returns the key value, regardless
// of the variable type. File variables therefore return the file contents
// and not the path name of the file.
func (b JobVariables) Value(key string) string {
        return b.value(key, false)
}

The change above causes GetDockerAuthConfig() to return the filename, which doesn't work.

What's the best way to test this MR?

  1. Generate an API token that allows you to read the registry on GitLab.com.
  2. Run docker login registry.gitlab.com.
  3. Grab the contents of ~/.docker/config.json.
  4. In a project, add DOCKER_AUTH_CONFIG as a File CI/CD variable with those contents.
  5. Run a CI job with GitLab 16.9.0 runner:
image: registry.gitlab.com/gitlab-org/security/charts/components/images/gitlab-webservice-ee:v16.9.0

stages:
  - test

test:
  stage: test
  script:
    - echo "hi"

For some reason, if I run gitlab-runner as root, I see the failure, but when I run it as my own user it doesn't. Not sure why.

What are the relevant issue numbers?

#37386 (closed)

Edited by Stan Hu

Merge request reports