0

I have a cloud_build.yaml script for my CI/CD pipeline on GP using Cloud Build. In command line I can pass a subtitution variable which will include the actual timestamp: "notebook-instance-$(date +%Y-%m-%d-%H-%M)-v05". This is working fine.

When I add github trigger on the Cloud Build webpage, then I didn't find the way to get the timestamp extracted in the same way that I was using in cli $(date +%Y-%m-%d-%H-%M)-v05: enter image description here

Any idea idea how to do that on the Triggers Cloud Build page ?

I aslo tried to do it inside the cloud_build.yaml script but without success for now.

- name: 'gcr.io/cloud-builders/gcloud'
  id: Deploy the AI Platform Notebook instance
  args: 
  - 'deployment-manager'
  - 'deployments'
  - 'create'
  - '$(date -u +%Y-%m-%d-%H-%M)-${_NAME_INSTANCE}'

Any idea how to extract and create a variable using the actual timestamp in the .yaml CloudBuild script ?

A third option is to extract the timestamp in my .jinja deployment script. Here I get the same issue as well that I don't find the way to to extract the actual timestampt to build my variable name.

Dr. Fabien Tarrade
  • 1,556
  • 6
  • 23
  • 49
  • I am puzzle that gcloud deployment-manager doesn't managed to extract the timestamp. It seems it works fine for gcloud docker: https://stackoverflow.com/questions/52337831/how-do-i-set-an-environment-or-substitution-variable-via-a-step-in-google-cloud.. – Dr. Fabien Tarrade Jun 14 '19 at 08:02

1 Answers1

0

One of the solution is to do the following:

- name: 'gcr.io/cloud-builders/gcloud'
  entrypoint: sh
  args: 
  - '-c'
  - |
    gcloud \
    deployment-manager \
    deployments \
    create \
    xxxx

The issue is that you cannot use it in another step later. Another option is is to write te variable in a file on the workspace. This can be access later during the build stackoverflow

Dr. Fabien Tarrade
  • 1,556
  • 6
  • 23
  • 49