Ruben Pretorius
Ruben Pretorius

Reputation: 353

GCP Cloud Build tag release

I have a GCP cloud build yaml file that triggers on a new Tag in Github.

I have configure the latest tag to diplay on the app engine version but I need to configure the cloudbuild.yml file to replace the full stop on my tag to hyphen otherwise it fails on the deployment phase.

  - id: web:set-env
    name: 'gcr.io/cloud-builders/gcloud'
    env:
      - "VERSION=${TAG_NAME}"
      
  #Deploy to google cloud app engine
  - id: web:deploy
    dir: "."
    name: "gcr.io/cloud-builders/gcloud"
    waitFor: ['web:build']
    args:
      [
        'app',
        'deploy',
        'app.web.yaml',
        "--version=${TAG_NAME}",
        --no-promote,
      ]

Tried using --version=${TAG_NAME//./-}, but getting an error on the deployment phase.

Upvotes: 0

Views: 1268

Answers (1)

Ruben Pretorius
Ruben Pretorius

Reputation: 353

Managed to replace te fullstop with n hyphen by using the below step in the cloudbuild.yml file:

  - id: tag:release
        name: 'gcr.io/cloud-builders/gcloud'
        args:
        - '-c'
        - |
          version=$TAG_NAME
          gcloud app deploy app.web.yaml --version=${version//./-} --no-promote
        entrypoint: bash

Upvotes: 3

Related Questions