concourse-slack-notifier icon indicating copy to clipboard operation
concourse-slack-notifier copied to clipboard

Use instance vars to format message

Open aoldershaw opened this issue 4 years ago • 3 comments

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.

Screen Shot 2021-01-22 at 11 25 31 AM

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!)

aoldershaw avatar Jan 22 '21 16:01 aoldershaw

👍 We started using instanced pipelines and this PR would come really handy!

RCM7 avatar Oct 21 '21 10:10 RCM7

@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

aoldershaw avatar Oct 21 '21 13:10 aoldershaw

thank you @aoldershaw 🙌

RCM7 avatar Oct 21 '21 19:10 RCM7