karluiz
karluiz

Reputation: 1

using gcloud beta builds triggers create cloud-source-repositories doesn't working with --dockerfile-image

I'm working on a auto devops workflow only based on the dockerfile using Cloud Build on GCP, when I try to use the following command it seems is not using the flag: --dockerfile-image

gcloud beta builds triggers create cloud-source-repositories \
--name="test-trigger-2" \
--repo="projects/nodrize-dev/repos/b722166a-56e0-46af-bd0d-42af8d37c570/bf11672f-34d5-4d8c-80cb-31120f39251a/quirino-backend" \
--branch-pattern="^master$" \
--dockerfile="Dockerfile" \
--dockerfile-dir="" \
--dockerfile-image="gcr.io/nodrize-dev/test-backend"

Created [https://cloudbuild.googleapis.com/v1/projects/nodrize-dev/triggers/896f8ac8-397c-464a-84f7-43e69f1bc6cb].
NAME            CREATE_TIME                STATUS
test-trigger-2  2021-06-02T21:06:54+00:00

I want to create trigger to run it later but the last flag isnt working I asume is using the default or fallback, because as you can see in the image name is: gcr.io/nodrize-dev/b722166a-56e0-46af-bd0d-42af8d37c570/bf11672f-34d5-4d8c-80cb-31120f39251a/quirino-backend:$COMMIT_SHA:

dockerimage-name in gcp concole: dockerimage-name in gcp concole

I hope someone can help me or at least know what is happening.

Upvotes: 0

Views: 463

Answers (1)

DazWilkin
DazWilkin

Reputation: 40316

This works for me.

I suspect perhaps that the trigger is incorrect or is not being triggered and|or the image is not what was generated by the trigger.

PROJECT=...
REPO=...

gcloud source repos create ${REPO} \
--project=${PROJECT}

gcloud beta builds triggers create cloud-source-repositories \
--name="trigger" \
--project=${PROJECT} \
--repo=${REPO} \
--branch-pattern="^master$" \
--dockerfile="Dockerfile" \
--dockerfile-dir="." \
--dockerfile-image="gcr.io/${PROJECT}/freddie-01"

NAME     CREATE_TIME                STATUS
trigger  2021-06-03T15:24:27+00:00

git push google master

gcloud builds list \
--project=${PROJECT} \
--format="value(images)"
gcr.io/${PROJECT}/freddie-01:7dcf74e126af711d24bb2b652d86f0d28bbe3bd9


gcloud container images list \
--project=${PROJECT}
NAME
gcr.io/${PROJECT}/freddie-01

Upvotes: 0

Related Questions