{"user":"cfcommunity","name":"slack-notification-resource","namespace":"cfcommunity","repository_type":"image","status":1,"status_description":"active","description":"Concourse CI resource for sending notifications to Slack","is_private":false,"is_automated":false,"star_count":6,"pull_count":2905866659,"last_updated":"2025-03-16T18:08:19.491831Z","last_modified":"2025-03-16T18:08:15.591898Z","date_registered":"2015-07-16T16:24:10.78356Z","collaborator_count":0,"affiliation":null,"hub_user":"cfcommunity","has_starred":false,"full_description":"[![Docker Stars](https://img.shields.io/docker/stars/cfcommunity/slack-notification-resource.svg?style=plastic)](https://registry.hub.docker.com/v2/repositories/cfcommunity/slack-notification-resource/stars/count/)\n[![Docker pulls](https://img.shields.io/docker/pulls/cfcommunity/slack-notification-resource.svg?style=plastic)](https://registry.hub.docker.com/v2/repositories/cfcommunity/slack-notification-resource)\n\u003c!--\n[![Concourse Build](https://ci.gstack.io/api/v1/teams/gk-plat-devs/pipelines/slack-notification-resource/jobs/build/badge)](https://ci.gstack.io/teams/gk-plat-devs/pipelines/slack-notification-resource)\n--\u003e\n[![dockeri.co](https://dockeri.co/image/cfcommunity/slack-notification-resource)](https://hub.docker.com/r/cfcommunity/slack-notification-resource/)\n\nSlack notification sending resource\n===================================\n\nSends messages to [Slack](https://slack.com).\n\nResource Type Configuration\n---------------------------\n\n```yaml\nresource_types:\n  - name: slack-notification\n    type: docker-image\n    source:\n      repository: cfcommunity/slack-notification-resource\n      tag:        latest\n```\n\nThe `tag: latest` source property is optional, as the value `latest` in the\ndefault.\n\nSource Configuration\n--------------------\n\nTo setup an Incoming Webhook, go to\n\u003chttps://my.slack.com/services/new/incoming-webhook/\u003e.\n\n- `url`: *Required.* The webhook URL as provided by Slack. Usually\n  in the form: `https://hooks.slack.com/services/XXXX`.\n\n- `insecure`: *Optional.* Connect to Slack insecurely - i.e. skip\n  SSL validation. Defaults to `false` if not provided.\n\n- `proxy`: *Optional.* Connect to Slack using an HTTP(S) proxy. In\n  the form: `http://my.proxy:3128`.\n\n- `proxy_https_tunnel`: *Optional.* Set to `true` to use an HTTP\n  proxy as an HTTPS tunnel.\n\n- `disable`: *Optional.* Set to `true` to skip all messaging.\n  Convenient for temporarily disabling notifications without editing\n  your pipelines.\n\n- `ca_certs`: *Optional.* An array of objects with the following\n  format:\n\n  ```yaml\n  ca_certs:\n    - domain: example.com\n      cert: |\n        -----BEGIN CERTIFICATE-----\n        ...\n        -----END CERTIFICATE-----\n    - domain: 10.244.6.2\n      cert: |\n        -----BEGIN CERTIFICATE-----\n        ...\n        -----END CERTIFICATE-----\n  ```\n\n  Each entry specifies the x509 CA certificate for the trusted\n  domain.\n\nExample:\n\n```yaml\nresources:\n  - name: slack-alert\n    type: slack-notification\n    source:\n      url: https://hooks.slack.com/services/XXXX\n```\n\nBehavior\n--------\n\n### `check` Step (`check` script): No operation\n\nChecking for new version always returns the last timestamp-based dummy\nversion, created when the last `put` step was executed on this resource.\n\n### `get` Step (`in` script): No operation\n\nGetting a new version of this resource does nothing else that always returning\nthe last timestamp-based dummy version, created when the last `put` step was\nexecuted on this resource.\n\n### `put` Step (`out` script): Sends a message to Slack.\n\nSend a message to Slack, with the configured parameters.\n\n#### Parameters\n\nYou must specify one or more of the following:\n\n- `text`: Static text of the message to send.\n\n- `text_file`: File that contains the message to send. This allows\n  the message to be generated by a previous task step in the\n  Concourse job.\n\n- `attachments`: An array of one or more message attachments. See\n  the [Slack documentation on message attachments][attach]\n  for the message structure.\n\n- `attachments_file`: File that contains the json attachments\n  array to send.  This parameter allows the attachments to be\n  generated by a previous task step in the Concourse job.\n\nIf you omit the `text` parameter, the content of the file\nspecified in the `text_file` parameter will be used verbatim.\nAlternatively, you can include the environment variable\n`$TEXT_FILE_CONTENT` in the `text` string to include the content\nof the file with other static text and interpolated variables (see\nMetadata section below.\n\nIf you use `text` without using the `$TEXT_FILE_CONTENT` in it,\nthe content will not be added to your message.\n\nThe `text` and `text_file` content can contain multiple lines,\nemojis like `:simple_smile:`, and links in form\n`\u003chttp://example.com\u003e` or `\u003chttp://example.com|Click here!\u003e`.\n\nTo mention a user, you will have to use the `\u003c@U123ABC\u003e` format,\nwhere `U123ABC` is the user ID. You can get a user's user ID by\nbrowsing their profile and using the **⌵** control to display and\nquickly copy and paste a specific user's ID. You can @mention a\ngroup using ` \u003c!subteam^S0123456789\u003e` You can find the user_groups\nid through the url on the slack website. For more ways, see\nthe [Slack documentation on username/user ID mapping][uidmap].\nYou can read more on how to mention users/channels in the [Slack\ndocumentation on linking to channels and users][chans].\n\n\nNote that the old `\u003c@username\u003e` format will soon no longer be\nsupported by Slack (See [changelog][cl2017]).\n\nIf you omit the `attachments` parameter, the contents of the file\nspecified in the `attachments_file` parameter will be used\nverbatim.  If the `attachments` parameter is set, then\n`attachments_file` will be ignored.  There is no way to use both\nat the same time.\n\nUnder the philosophy that its better to write something than fail\nsilently, the following will be sent under these conditions:\n\n- when `text`, `attachments`, `attachments_file` are omitted, and...\n\n  - `text_file` omitted, or present but file missing:\n    \u003e *(no notification given)*\n  - `text_file` specified and present but file empty:\n    \u003e *(missing notification text)*\n\n- when `text` is present and both `attachments` and\n  `attachments_file` are omitted, and `text` evaluates to empty\n  string after variable interpolation:\n\n  \u003e *(missing notification text)*\n\n- when `text` specified with `$TEXT_FILE_CONTENT` and more content, and...\n  - `text_file` omitted, or present but file missing\n    * `$TEXT_FILE_CONTENT` is replaced with \"*(no notification given)*\"\n  - `text_file` specified and present but file empty:\n    * no notification is sent\n\nOptional:\n\n- `channel`: *Optional.* Override channel to send message to.\n  `#channel` and `@user` forms are allowed. You can notify multiple\n  channels separated by whitespace, like `#channel @user`.\n\n- `channel_file`: *Optional.* File that contains a list of\n  channels to send message to. If `channel` is also specified, the\n  two lists will be concatenated.\n\n- `env_file`: *Optional.* File that contains a list of `key=value`\n  environment variables that will be available in your slack\n  messages template.\n\n- `username`: *Optional.* Override name of the sender of the message.\n\n- `icon_url`: *Optional.* Override icon by providing URL to the image.\n\n- `icon_emoji`: *Optional.* Override icon by providing emoji code\n  (e.g. `:ghost:`).\n\n- `silent`: *Optional.* Do not print curl output (avoids leaking\n   slack webhook URL).\n\n- `always_notify`: *Optional.* Attempt to notify even if there are\n  errors or missing text. (Expects true or false, defaults to\n  false).\n\nExplore formatting with Slack's [Message Builder][build].\n\n[attach]: https://api.slack.com/reference/messaging/attachments\n[uidmap]: https://api.slack.com/changelog/2017-09-the-one-about-usernames#mapping\n[chans]:  https://api.slack.com/docs/message-formatting#linking_to_channels_and_users\n[cl2017]: https://api.slack.com/changelog/2017-09-the-one-about-usernames\n[build]:  https://api.slack.com/docs/formatting/builder\n\n\n#### Metadata\n\nVarious metadata is available in the form of environment\nvariables. Any environment variables present in the parameters\nwill be automatically evaluated; this enables dynamic parameter\ncontent.\n\nThe following pipeline config snippet demonstrates how to\nincorporate the metadata:\n\n```yaml\n---\njobs:\n- name: some-job\n  plan:\n  - put: slack-alert\n    params:\n      channel: '#my_channel'\n      text_file: results/message.txt\n      text: |\n        The build had a result. Check it out at:\n        http://my.concourse.url/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME\n        or at:\n        http://my.concourse.url/builds/$BUILD_ID\n\n        Result: $TEXT_FILE_CONTENT\n```\n\nSee the [official documentation][meta] for a complete list of\navailable metadata.\n\n[meta]:   https://concourse-ci.org/implementing-resource-types.html#resource-metadata\n\nExamples\n--------\n\nIf you're interested in the API of Concourse resources and/or\ncontributing to this resource, you can play with the `out` script\nusing examples. There are some available in the `test` folder.\n\nNote: they have a `params.debug` set so that it only prints out\nthe data structures rather than attempting to invoke the Slack\nAPI. Remove it and set a real Slack API to test the script against\nSlack.\n\n```\n\u003e cat test/combined_text_template_and_file_empty.out | ./out .\nwebhook_url: https://some.url\nbody: {\n  \"text\": \":some_emoji:\u003chttps://my-ci.my-org.com//teams//main//pipelines//jobs//builds/|Alert!\u003e\\n\",\n  \"username\": \"concourse\",\n  \"icon_url\": null,\n  \"icon_emoji\": null,\n  \"channel\": null\n}\n\n\u003e cat test/combined_text_template_and_file_missing.out | ./out .\nwebhook_url: https://some.url\nbody: {\n  \"text\": \":some_emoji:\u003chttps://my-ci.my-org.com//teams//main//pipelines//jobs//builds/|Alert!\u003e\\n_(no notification provided)_\\n\",\n  \"username\": \"concourse\",\n  \"icon_url\": null,\n  \"icon_emoji\": null,\n  \"channel\": null\n}\n\n\u003e cat test/combined_text_template_and_file.out | ./out .\nwebhook_url: https://some.url\nbody: {\n  \"text\": \":some_emoji:\u003chttps://my-ci.my-org.com//teams//main//pipelines//jobs//builds/|Alert!\u003e\\nThis text came from sample.txt. It could have been generated by a previous Concourse task.\\n\\nMultiple lines are allowed.\\n\",\n  \"username\": \"concourse\",\n  \"icon_url\": null,\n  \"icon_emoji\": null,\n  \"channel\": null\n}\n\n\u003e cat test/text_file_empty.out | ./out .\nwebhook_url: https://some.url\nbody: {\n  \"text\": \"_(missing notification text)_\\n\",\n  \"username\": \"concourse\",\n  \"icon_url\": null,\n  \"icon_emoji\": null,\n  \"channel\": null\n}\n\n\u003e cat test/text_file.out | ./out .\nwebhook_url: https://some.url\nbody: {\n  \"text\": \"This text came from sample.txt. It could have been generated by a previous Concourse task.\\n\\nMultiple lines are allowed.\\n\",\n  \"username\": \"concourse\",\n  \"icon_url\": null,\n  \"icon_emoji\": null,\n  \"channel\": null\n}\n\n\u003e cat test/text.out | ./out .\nwebhook_url: https://some.url\nbody: {\n  \"text\": \"Inline static text\\n\",\n  \"username\": \"concourse\",\n  \"icon_url\": null,\n  \"icon_emoji\": null,\n  \"channel\": null\n}\n```\n\n\n\n\n\n\n## Authors and license\n\nCopyright © 2017-2020,    James Hunt\u003cbr/\u003e\nCopyright © 2021-present, Benjamin Gandon, Gstack\n\nThe Slack notification resource is released under the terms of the\n[MIT license](./LICENSE).\n\n\u003c!--\n# Local Variables:\n# indent-tabs-mode: nil\n# End:\n--\u003e","permissions":{"read":true,"write":false,"admin":false},"media_types":["application/vnd.docker.container.image.v1+json","application/vnd.docker.distribution.manifest.v1+prettyjws"],"content_types":["image"],"categories":[],"immutable_tags_settings":{"enabled":false,"rules":[".*"]},"storage_size":1324213511,"source":null}