google cloud platform – Where did my cloudbuild.yaml come from? And why does it error with a Dockerfile?

The cloudbuild.yaml file is a configuration file that is used by Cloud Build to specify how to build and deploy your application. When you create a Cloud Build trigger, Cloud Build will automatically generate a cloudbuild.yaml file for you. This file will include the necessary steps to build and deploy your application based on the information you provide when you create the trigger.

In your case, when you created the Cloud Build trigger in project A, Cloud Build generated a cloudbuild.yaml file that included the necessary steps to build your application using the Dockerfile in your repository. This is why you were able to successfully build and deploy your application in project A.

When you tried to create a Cloud Build trigger in project B, Cloud Build did not generate a cloudbuild.yaml file because you did not provide any information about how to build your application. As a result, Cloud Build was not able to determine how to build your application and the build failed.

To get Cloud Build to generate a cloudbuild.yaml file for you in project B, you need to provide Cloud Build with some information about how to build your application. You can do this by specifying the build_config field in the Cloud Build trigger configuration. The build_config field can be used to specify the location of a cloudbuild.yaml file or to provide inline Cloud Build configuration.

For example, if you have a cloudbuild.yaml file in your repository, you can specify the location of the file in the build_config field as follows:

build_config:
  location: 'cloudbuild.yaml'

Alternatively, you can provide inline Cloud Build configuration in the build_config field as follows:

build_config:
  steps:
  - name: 'gcr.io/cloud-builders/docker'
    args: ['build', '-t', 'gcr.io/$PROJECT_ID/my-image', '.']
  - name: 'gcr.io/cloud-builders/docker'
    args: ['push', 'gcr.io/$PROJECT_ID/my-image']
  images:
  - 'gcr.io/$PROJECT_ID/my-image'

Once you have provided Cloud Build with some information about how to build your application, Cloud Build will be able to generate a cloudbuild.yaml file for you.

In your case, you can copy the cloudbuild.yaml file from project A and use it in project B. However, you will need to replace the substitution arguments in the file with the appropriate values for project B. For example, you will need to replace the $PROJECT_ID substitution argument with the project ID for project B.

Once you have replaced the substitution arguments, you can use the cloudbuild.yaml file to create a Cloud Build trigger in project B. The Cloud Build trigger will use the cloudbuild.yaml file to build and deploy your application.

I hope this helps! Let me know if you have any other questions.

Read more here: Source link