Search code examples
google-cloud-build

Tags column not set in build history


I have just started to using Google Cloud Build for one of my projects. One thing that bugs me is that I cannot get data into the tags column in the build history, the only data there is some auto generated tags containing the trigger id.

Here: Current build results

I have configured tags in the build trigger:

Build trigger

Looks correct to me when reading the docs:

https://cloud.google.com/build/docs/view-build-results#filter_build_results_by_using_tags

I have tried with both manual and web hook triggers, same result. What am I missing, how to make the configured tags show up in the build history? I would expect the tags column to contain "nightly", not "trigger-...."


Solution

  • Seems you have added tags at the wrong place. To filter build results with tags you have to add tags in the cloud build configuration file(cloudbuild.yaml or Dockerfile) not in the trigger tags section. Tags in triggers can be used to filter triggers only.

    I have tried this on my end.When i have added tag in trigger same as you, After running the trigger i am also unable to view the tag checking in build history. As I mentioned above, if you have multiple triggers and if you want to filter them based on tags you can use tags in the console to filter them as shown here.

    As you want to filter build history based upon tags you need to add the tags section in your build config file as mentioned in the document.See below example on how to add tags in build configuration file.

        steps:
        - name: 'gcr.io/cloud-builders/docker'
          args: [ 'build', '-t', 'us-east1-docker.pkg.dev/$PROJECT_ID/cb-demo-img', '.' ]
        images:
        - 'us-east1-docker.pkg.dev/$PROJECT_ID/cb-demo-img'
        tags:
        - 'check2'
    

    Once you have added tags as above, After triggering the builds tags will be shown in build history like as shown here.FYI, in image trigger-... represents the trigger id and it will be unique for all the builds for the respective triggers in build history.If no tags have been added to configuration it will show trigger id only. If tags are added it will show tags along with trigger id.