1

I have two GitHub repos (let's call them Repo1 and Repo2) in two Cloud Build triggers. Both have the same Service Account, GitHub account, GCP project, and both repos exist in Artifact Registry.

Repo1's Docker image is pushed to the Artifact Registry but the problem is Repo2's image does not appear in the Artifact Registry.

No error appears in Repo2's Build log. But the Repo2's Build logs stop at the tag phase:

Step #0: Successfully built 4c46XXXX 
Step #0: Successfully tagged us-docker.pkg.dev/my-project/repo2/main:latest  
Finished Step #0  

As comparison, Repo1's Build log indicates the Docker image is created AND pushed to Artifact Registry:

Successfully built XXXXX
Successfully tagged us-docker.pkg.dev/my-project/repo1/repo1:latest
PUSH
Pushing us-docker.pkg.dev/my-project/repo1/repo1
The push refers to repository [us-docker.pkg.dev/my-project/repo1/main]
... 
XXX: Layer already exists
XXX: Pushed
latest: digest: sha256:XXXXXX
DONE

cloudbuild.yaml for Repo1:

steps:
  - name: gcr.io/cloud-builders/docker
    args: [build, -t, $_GCR/$PROJECT_ID/$REPO_NAME/$BRANCH_NAME, "."]
images: [$_GCR/$PROJECT_ID/$REPO_NAME/$BRANCH_NAME]
options:
  logging: CLOUD_LOGGING_ONLY
substitutions:
  _GCR: us-docker.pkg.dev

NOTE: $REPONAME is "repo1".

Repo1 has the Artifact Registry path at us-docker.pkg.dev/my-project/repo1 and I can verify the output as successful.

cloudbuild.yaml for Repo2:

steps:
  - name: gcr.io/cloud-builders/docker
    args:
      [
        build,
        -t,
        us-docker.pkg.dev/$PROJECT_ID/$_SERVICE_NAME/$BRANCH_NAME,
        -f,
        Dockerfile,
        ".",
      ]
    id: Build service
  - name: gcr.io/cloud-builders/docker
    entrypoint: docker
    args:
      [
        run,
        SERVICE_NAME=$_SERVICE_NAME,
        $_VM_CLEANUP_IMAGE,
      ]
  id: Deleting oldest VM for service
tags: [$COMMIT_SHA, $TRIGGER_NAME]
images: [us-docker.pkg.dev/$PROJECT_ID/$_SERVICE_NAME/$BRANCH_NAME]
options:
  logging: CLOUD_LOGGING_ONLY
substitutions: 
  _SERVICE_NAME: "repo2"

Repo2 has the Artifact Registry path at us-docker.pkg.dev/my-project/repo2 which is empty.

I've tried:

engineer-x
  • 2,173
  • 2
  • 12
  • 25
  • This question does not seem programming-, but rather deployment- and infrastructure-related and is therefore off-topic for Stack Overflow. It might be a better fit for [sf] or [DevOps](https://devops.stackexchange.com/). – Turing85 Dec 30 '22 at 01:25
  • 1
    As per your latest edit, seems like you solved your issue. Can you share it as solution so that it helps others? – Roopa M Dec 30 '22 at 07:33

1 Answers1

1

It appears my issue is due to a failing step in the build process, "Deleting oldest VM for service". I know this because I removed the failing step and the Docker image appeared in the Artifact Registry where I expected it, solving this question.

From this experience it seems that any failing step can cause problems in the previous steps in the build process. I speculate that the failing step keeps the service from getting to the images: field which is responsible for pushing to the registry.

engineer-x
  • 2,173
  • 2
  • 12
  • 25