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

Simplified Environment Variable Export for Custom Templates #454

Open
mlachkar-da opened this issue Aug 14, 2024 · 1 comment
Open

Simplified Environment Variable Export for Custom Templates #454

mlachkar-da opened this issue Aug 14, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@mlachkar-da
Copy link

Describe Request:

Currently, when using custom templates in the CircleCI Slack Orb, users need to manually handle the export of environment variables to customize the template fields. This process can be cumbersome and error-prone.
Maybe we could introduce an environment key under the slack/notify job where users can define environment variables directly within the CircleCI configuration. These variables would then be automatically available within the custom Slack templates, reducing the need for manual export steps.

Examples:

- slack/notify:
    channel: some-channel
    branch_pattern: main
    template: basic_fail_2
    environment:
      FAILURE_MESSAGE: "Please take care of this issue ${SELECTED_VOLUNTEER}!"

Thanks!

@marboledacci marboledacci added the enhancement New feature or request label Sep 17, 2024
@marboledacci marboledacci self-assigned this Oct 21, 2024
@marboledacci
Copy link
Contributor

Hi @mlachkar-da unfortunately the solution you propose is not possible today on CircleCI as the parameters cannot be a map.
But you have several ways to pass multiple environment variables without manual exports. The first one is to use a context, you can create a context with all the variables you need on the template and pass it to the job call like this:

- your-job:
    context: SLACK_TEMPLATE

The second is to use a docker executor and pass the environment to the executor, it would look like this on the job definition:

docker:
- image: ubuntu
  environment:
    FAILURE_MESSAGE: "Please take care of this issue ${SELECTED_VOLUNTEER}!"
steps:
- slack/notify:
    channel: some-channel
    branch_pattern: main
    template: basic_fail_2

And the last one is to pass the environment on the job definition:

environment:
  FAILURE_MESSAGE: "Please take care of this issue ${SELECTED_VOLUNTEER}!"
steps:
- slack/notify:
    channel: some-channel
    branch_pattern: main
    template: basic_fail_2

You can get more information about passing environment variables here

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

No branches or pull requests

2 participants