Send notification messages to any webhook from a Concourse CI pipeline.
This resource provides:
Pre-formatted markdown messages, with colorful icons, for every Concourse job status.
Integration with Gitter activity feeds.
Extensible design to easily add support for other webhooks. (See Contributing for more information.)
Concourse is an open-source continuous thing-doer. It's pretty amazing for CI and for more complicated pipelines, you should check it out.
It's pretty common to want to send notification messages somewhere when a job succeeds or fails. Sometimes it's just an HTTP POST or other similarly simple action. This resource tries to make it easy to have a polished-looking informational message for these simple integrations.
For more information on Concourse Resources:
These parameters go into the source fields of the resource.
Required
adapter: The name of the service adapter you want to use.
resource/lib/adapters.GitterActivityFeedAdapter, MockTeapoturl: The target webhook URL.Optional
dryrun: When set to true, the resource does not make any HTTP requests. (Defaults to false)check and inThis resource only supports the put step, so these are no-ops in this resource.
output will connect to the webhook and send the configured markdown message.
This resource comes with some standard pre-formatted messages to reflect typical Concourse job status. You can easily send these messages by setting the following parameter:
status: Set to one of the states named below to get a sane, well-formatted message.Valid status values:
aborted will post the contents of resource/messages/aborted.mderrored will post the contents of resource/messages/errored.mdfailed will post the contents of resource/messages/failed.mdpending will post the contents of resource/messages/pending.mdstarted will post the contents of resource/messages/started.mdsucceeded will post the contents of resource/messages/succeeded.mdAny other value will post the contents of resource/messages/unknown.md.
To send a custom message, exactly one of the following parameters must be present:
message: The markdown-formatted text of the notification to be sent.message_file: Path to a file containing the markdown-formatted text of the notification to be sent.Any Concourse metadata in the message string or in the text contents of message_file will be evaluated prior to sending the message. If the notification text contains newlines then it will be split into multiple IRC message sends.
${ATC_EXTERNAL_URL}/teams/${BUILD_TEAM_NAME}/pipelines/${BUILD_PIPELINE_NAME}/jobs/${BUILD_JOB_NAME}/builds/${BUILD_NAME}
Here's how the resource might be configured to send pre-formatted markdown messages to a Gitter channel activity feed in a Concourse pipeline file:
resource_types:
- name: webhook-notification
type: docker-image
source:
repository: flavorjones/webhook-notification-resource
resources:
- name: foobar-gitter-channel
type: webhook-notification
source:
adapter: GitterActivityFeedAdapter
url: ((webhook_url))
jobs:
- name: run-some-tests
plan:
- task: run-a-test
config: { ... }
on_success: { put: foobar-gitter-channel, params: {status: "success"} }
on_failure: { put: foobar-gitter-channel, params: {status: "failure"} }
on_error: { put: foobar-gitter-channel, params: {status: "error"} }
on_abort: { put: foobar-gitter-channel, params: {status: "abort"} }
And here's how you can configure a custom message:
resource_types:
- name: webhook-notification
type: docker-image
source:
repository: flavorjones/webhook-notification-resource
resources:
- name: foobar-gitter-channel
type: webhook-notification
source:
adapter: GitterActivityFeedAdapter
url: ((webhook_url))
- name: post-a-message-to-gitter
plan:
- put: foobar-gitter-channel
params:
message: "_This_ is a *markdown* message about [${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME}}](${BUILD_URL})"
See docs/gitter-create-webhook.md.
The following features seem like reasonable things to implement, but I just haven't gotten around to them yet. If you'd like to help implement these, please do!
Pull requests are welcome, as are Github issues opened to discuss bugs or desired features.
If you'd like to integrate with a new service:
resource/lib/adapters named after your ClassName in snake_case..post(url_string, message)It's totally possible that your adapter might need to be a real class (not just a module) and take additional arguments (like the config params). If so, let's talk!
If you have questions, please reach out! I shipped this in a hurry so this section is definitely not as explanatory as I'd like.
Requirements:
To build an OCI image and run the tests in that image:
$ make test
This iteration loop is slightly slower than working with a local Ruby environment (~3 seconds on my laptop).
Requirements:
$ bundle install && bundle exec rake test
This iteration loop is slightly faster than working inside a docker container (~1 second on my laptop).
MIT. See the file named LICENSE in this repository.
Content type
Image
Digest
Size
37 MB
Last updated
over 5 years ago
docker pull flavorjones/webhook-notification-resource