concourse-slack-notifier
concourse-slack-notifier copied to clipboard
Use instance vars to format message
Follow-up to (and depends on) mockersf/concourse-resource-rs#1, which adds a pipeline instance vars to the BuildMetadata
. For context, I'll copy the PR description:
I'm a member of the Concourse team, and one feature we're adding to Concourse v7.0.0 is pipeline instances. The RFC outlines the motivations for the feature/how it works at a high-level. One implication of pipeline instances is that the team name + pipeline name is no longer sufficient to uniquely identify a pipeline in general - pipeline instances are also identified by their "instance vars", which is some JSON object. For instance, you may have an instance group called release, and several pipeline instances for different versions, e.g.
{"version": "6.7.x"} {"version": "7.0.x"} ...
Accordingly, resources are now given the instance vars as a JSON encoded string in BUILD_PIPELINE_INSTANCE_VARS. Regular pipelines will have this env var unset.
This updates the job+build name in the message to display the instance vars in the job reference, and updates the build URL with the appropriate query params. e.g.

Note that the format of the pipeline/job reference is meant to mimic how you interact with pipeline instances in fly. For the above example, we could say:
$ fly -t ci trigger-job -j 'release/type:"hg"/build-alpine'
# the quotes are optional here
$ fly -t ci trigger-job -j release/type:hg/build-alpine
Of course open to any/all feedback! I'm very much a rust novice, so if I did something in a stupid way, please let me know (I'd love to learn best practices!)
👍 We started using instanced pipelines and this PR would come really handy!
@RCM7 in the meantime, you can use the resource type built from this PR, as the Concourse team has been doing: https://github.com/concourse/ci/blob/db479438ca5b181afda962571ed9f243529f4df4/pipelines/release.yml#L41-L45
thank you @aoldershaw 🙌