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

Ability to specify notification color in slack #63

Open
M0nsieurChat opened this issue Jan 21, 2019 · 3 comments
Open

Ability to specify notification color in slack #63

M0nsieurChat opened this issue Jan 21, 2019 · 3 comments

Comments

@M0nsieurChat
Copy link

M0nsieurChat commented Jan 21, 2019

Hello !

First of all, thanks for your amazing work !

Would it be possible to introduce a new attribute color: so that we could specify which color would be applied to the text notification inside Slack ?

I think this is possible because our other slack integrations will apply different colors for different notifications statuses

screenshot from 2019-01-21 12-35-43
screenshot from 2019-01-21 12-35-28

Doing so could differentiate on_success and on_failure notifications and make more clear which builds failed and which builds succeed

Thanks,

@jhunt
Copy link
Contributor

jhunt commented Jan 21, 2019

Definitely! Is that something you would be interested in working on / submitting a PR for?

@M0nsieurChat
Copy link
Author

Looking at the slack documentation, it seems this "color" is only achievable through attachments : https://api.slack.com/docs/message-attachments

Fortunately, there is an attachments: parameter so I might be able to reproduce this without altering the container resource.

@M0nsieurChat
Copy link
Author

M0nsieurChat commented Jan 21, 2019

This works :

  on_success:
    put: slack-notification
    params:
      text: "Build ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME} #${BUILD_NAME} successful - ${ATC_EXTERNAL_URL}/teams/main/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}"
      attachments:
        - text: "Success !"
          color: "#36a64f"

screenshot from 2019-01-21 18-28-17

One would want to use the ${text_interpolated} inside the text: attribute of the attachment but this would require some work on the out bash file : https://github.com/cloudfoundry-community/slack-notification-resource/blob/master/out#L134

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

No branches or pull requests

2 participants