Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slack notification: {{.Params.buildStatus}} substitution not working #188

Open
scr4bble opened this issue Jan 15, 2024 · 5 comments
Open

Comments

@scr4bble
Copy link

scr4bble commented Jan 15, 2024

EDIT: found out that this param was missing in the YAML config file that was supposed to provide it. So then it's just the first question that remains: where to find a list of all variables that can be used?

1st thing:
It would be really great to have a list of all available variables for the notification files.

2nd thing:
I have used this text inside slack.json notification file (taken from this example file):
"Cloud Build in {{.Build.ProjectId}} for branch {{.Build.Substitutions.BRANCH_NAME}} finshed with status *{{.Params.buildStatus}}*"
and it resulted into
... with status *<no value>*

Any idea why this behavior?
Also - do you have any link to display all possible variables? It could go into Readme file.

@rootsher
Copy link

same problem

@VuKrampHub
Copy link
Contributor

I think you can find all possible variables here:
https://cloud.google.com/build/docs/api/reference/rest/v1/projects.builds#resource:-build

@prabenzom
Copy link
Contributor

Thanks for the link @VuKrampHub. Does that resolve your question @scr4bble >

@scr4bble
Copy link
Author

scr4bble commented Apr 2, 2024

I guess that partially it does. But I find the linked docs quite extensive, so I would need time to review it in order to evaluate. First thing that comes to my mind is: does the case sensitivity matter here? I see there is "build" variable in the posted URL for build resource but I see {{.Build.ProjectId}} in the slack.json file and I don't understand why is it different. It would be really great if this all is explained inside docs directly in this project (e.g. in the Readme file) - how exactly to use the variables and where to find the list of available variables (could be the linked docs if that is the source but I am not able to verify this).

@VuKrampHub
Copy link
Contributor

@scr4bble I indeed had the same confusion from the start. The link I shared is the possible structure of the build object containing all available variables. When it is referred in the template file, it is as .Build. The same with its properties, they also start with uppercase letter.

The caveat is for some it's hard to determine how to refer to them from the linked doc such as Source property as there can be multiple inherited types. What I do in this case is to look at the actual build object, which you can capture from cloud-builds topic message and decode using any base64 decoder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants