Sends messages to Slack.
url
: Required. The webhook URL as provided by Slack. Usually in the form:https://hooks.slack.com/services/XXXX
Send message to Slack, with the configured parameters.
Required:
Either of the following parameters are required:
text
: Static text of the message to send.text_file
: File that contains the message to send. This allows the message to be generated by a previous task step in the Concourse job.
The text can contain links in form <http://example.com>
or <http://example.com|Click here!>
.
Optional:
channel
: Optional. Override channel to send message to.#channel
and@user
forms are allowed.username
: Optional. Override name of the sender of the message.icon_url
: Optional. Override icon by providing URL to the image.icon_emoji
: Optional. Override icon by providing emoji code (e.g.:ghost:
).silent
: Optional. Do not print curl output (avoids leaking slack webhook URL)
Various metadata is available in the form of environment variables. Any environment variables present in the parameters will be automatically evaluated; this enables dynamic parameter content.
The following pipeline config snippet demonstrates how to incorporate the metadata:
---
jobs:
- name: some-job
plan:
- put: slack-alert
params:
channel: '#my_channel'
text: |
The build had a result. Check it out at:
http://my.concourse.url/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME
or at:
http://my.concourse.url/builds/$BUILD_ID
See the official documentation for a complete list of available metadata.
If you're interested in the API of Concourse resources and/or contributing to this resource, you can play with the out
script using examples. There are some available in the examples
folder.
Note: they have a params.debug
set so that it only prints out the data structures rather than attempting to invoke the Slack API. Remove it and set a real Slack API to test the script against Slack.
$ cat examples/text.out | ./out
webhook_url https://some.url
body {"text":"Inline static text","username":"concourse","icon_url":null,"icon_emoji":null,"channel":null}
$ cat examples/text_file.out | ./out
webhook_url https://some.url
body {"text":"This text came from sample.txt. It could have been generated by a previous Concourse task.","username":"concourse","icon_url":null,"icon_emoji":null,"channel":null}