Skip to content

Dynamic Templates

Jason Yonker edited this page Oct 25, 2024 · 1 revision

Dynamic Glue Orb Templates

It is possible to dynamically write or create a Glue orb template as a part of the job the orb is running in, and then have the orb pick up that template at the time of sending the notification.

This means it is possible to write orbs that can be used with the Glue orb to send special notifications.


1. Generate the Template

Either within your config or as a part of your orb's command, write to a file your orb template.

You can structure your template using Markdown for message formatting instead of Block Kit.

  • Generate orb template
  • Write to /tmp/MyOrbName/GlueTemplate.md

2. Export Template to Environment Variable

With your template file in the system, we can now export the template as an environment variable. On CircleCI, we need to make use of the $BASH_ENV environment variable to persist our environment across steps.

echo 'export MY_ORB_TEMPLATE=$(cat /tmp/MyOrbName/GlueTemplate.md)' >> $BASH_ENV

3. Use the Template

You may now use the template within the Glue orb later in the job as if it were any of the included default templates.

- glue/notify:
    event: fail
    template: MY_ORB_TEMPLATE
    target: thr_ABC123