Repository navigation
Description
When using a Concourse resource as notification mechanism (say to update the GitHub Commit status, or to send a chat message), the configuration is verbose and redundant, also if "optimised" with YAML anchors. For example:
cogito-handlers: &cogito-handlers
on_success:
put: cogito
# redundant: I am telling the resource that the state is `success`, but the handler is `on_success`
params: {state: success}
on_failure:
put: cogito
# same redundancy for all the other handlers
params: {state: failure}
on_error:
put: cogito
params: {state: error}
on_abort:
put: cogito
params: {state: abort}Then this YAML anchor is referenced in the rest of the pipeline:
jobs:
- name: autocat
<<: *cogito-handlers
plan:
- get: repo.git
...When running the put step, the resource has already access to the following resource metadata:
$BUILD_ID$BUILD_NAME$BUILD_JOB_NAME$BUILD_PIPELINE_NAME$BUILD_PIPELINE_INSTANCE_VARS$BUILD_TEAM_NAME$BUILD_CREATED_BY$ATC_EXTERNAL_URL
By looking at the metadata, I realized that the resource has enough information to query the ATC, get the build state associated to the $BUILD_ID and allow the configuration to be less verbose and more natural:
cogito-handlers: &cogito-handlers
on_success:
put: cogito
on_failure:
put: cogito
on_error:
put: cogito
on_abort:
put: cogitoBut querying the ATC adds another possibility for failure and especially requires to provide to the resource the local credentials of a Concourse user. Also if the user can be restricted to read-only access via the viewer role, it is still giving the resource more permissions than it really needs.
Thus the proposal: if we added to the resource metadata the build state, say
$BUILD_STATE
we could gain the reduced verbosity shown above without the complexity and risk of giving user credentials to the resource.
Regarding #6600, in my understanding it would require so many other changes (prototypes and notification itself) that I don't see it happening soon.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
marco-m commentedon Sep 10, 2022
Hello @xtremerui, opinions? :-)
kallisti5 commentedon Feb 14, 2023
I'd strongly support this. It would greatly assist in #8686 as well
evanchaoli commentedon Feb 16, 2023
To clarify,
on_successetc. hooks can be used on any step. Only when they are used at job level, they may getBUILD_STATE.I just quickly checked related code, technically it's possible to add this feature.
taylorsilva commentedon Jan 7, 2025
This is a great idea! Anyone is free to open a PR implementing this. I'll review and merge it.
analytically commentedon Apr 22, 2025
I suggest we set 'BUILD_STATUS' as env var as it's more commonly used and more intuitive?
I can open a PR?
feat(atc): natively inject BUILD_STATE into resource metadata