KTT
KTT

Reputation: 321

how to send value to pub/sub when Cloud Build all step finished

I want to send target property value to pub/sub after all step of cloud build finish

var target = "test"

op, err := cloudbuildService.Projects.Builds.Create(os.Getenv("GOOGLE_CLOUD_PROJECT"), &cloudbuild.Build{
        Steps: []*cloudbuild.BuildStep{
            {...},
            {...}
        },
        Artifacts: &cloudbuild.Artifacts{
            Objects: &cloudbuild.ArtifactObjects{
                Location: dst,
                Paths:    []string{...},
            },
        },
    }).Do()

please tell me how to do it

Upvotes: 0

Views: 610

Answers (1)

guillaume blaquiere
guillaume blaquiere

Reputation: 75775

You can't customize the PubSub message envelop send at the end of the Cloud Build builds. The content of the PubSub message is the as Build resource in the message.data described in the documentation

Because you will receive the Build resource description, a workaround is to add a dummy substitution variable name "_TARGET" and with the value that you want.

In a subsequent process, you will be able to get this value and act accordingly. However, because it's not a PubSub attribute, you won't be able to leverage the pubsub filter feature.

Upvotes: 1

Related Questions