user1068378
user1068378

Reputation: 319

cloud build trigger based on github commits does not work

i have the following build.yaml to build an image for my project

steps:
  # Build the container image with the Python version of our choice.
  - name: gcr.io/cloud-builders/docker
    args:
      [ 'build'
      , '--tag=gcr.io/$PROJECT_ID/$_IMAGE_NAME'
      , '--file=./Dockerfile_pipeline'
      , '.'
      ]
    
      
images: ['gcr.io/$PROJECT_ID/$_IMAGE_NAME']


substitutions:
  _IMAGE_NAME: pipeline:latestRun

This works fine when kicked off in gcp console via

gcloud beta builds submit     --verbosity debug     --config  build.yaml

However, when i create a cloudbuild trigger (based on commits on my repo) that kicks off my build.yaml i am getting the following error

starting build "4cc47363-32f5-4862-8533-90810c972c5a"

FETCHSOURCE
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
hint:   git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 
hint:   git branch -m <name>
Initialized empty Git repository in /workspace/.git/
From https://github.com/mmistroni/GCP_Experiments
 * branch            450bfce1f17042d3163e39a3ecad89d06922ea47 -> FETCH_HEAD
HEAD is now at 450bfce adding marketloader trigger
BUILD
Already have image (with digest): gcr.io/cloud-builders/docker
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /workspace/Dockerfile_pipeline: no such file or directory
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 1

What am i missing?

kind regards marco

Upvotes: 0

Views: 469

Answers (1)

user1068378
user1068378

Reputation: 319

i found the solution after fiddling for a while When the trigger is kicked off from github commit, the root directory is the root my repo, GCP_Experiments the dockerfile instead resides in GCP_Experiments\dataflow\pipeline\Dockerfile_pipeline So i had to do two fixes 1 - put the full path of the docker file as --file argument 2 - specify, as a PATH parameter, the directory where file resides relative to root repo, aka ./dataflow/pipeline

rgds

Upvotes: 1

Related Questions