Git Product home page Git Product logo

concourse-slack-notifier's Introduction

concourse-slack-notifier License: Apache-2.0 Build Status Docker Pulls Image Informtations

A structured and opinionated Slack notification resource for Concourse. It started as a rewrite of arbourd/concourse-slack-alert-resource in Rust to add a few features, mainly reading the message from a file or being able to send shorter messages that still had a similar format.

The message is built by using Concourse's resource metadata to show the pipeline, job, build number and a URL.

Installing

Use this resource by adding the following to the resource_types section of a pipeline config:

resource_types:

- name: slack-notifier
  type: docker-image
  source:
    repository: mockersf/concourse-slack-notifier

See the Concourse docs for more details on adding resource_types to a pipeline config.

Source Configuration

  • url: Required. Slack webhook URL.
  • channel: Optional. Target channel where messages are posted. If unset the default channel of the webhook is used.
  • concourse_url: Optional. The external URL that points to Concourse. Defaults to the env variable ATC_EXTERNAL_URL.
  • username: Optional. Concourse local user (or basic auth) username. Required for non-public pipelines if using alert type fixed or broke
  • password: Optional. Concourse local user (or basic auth) password. Required for non-public pipelines if using alert type fixed or broke
  • ca_cert: Optional. A CA certificate for the Concourse instance. This is used to validate the certificate of Concourse when the instance's certificate is signed by a custom authority (or itself).
  • ignore_ssl: Optional. This option allows unsecure access to Concourse (not verifying certificates).
  • disabled: Optional. This option will disable all notifications from this resource.
resources:

- name: notify
  type: slack-notifier
  source:
    url: https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX

Behavior

check: No operation.

in: No operation.

out: Send a message to Slack.

Sends a structured message to Slack based on the alert type and mode.

Parameters

  • alert_type: Optional. The type of alert to send to Slack. See Alert Types. Defaults to custom.
  • channel: Optional. Channel where this message is posted. Defaults to the channel setting in Source.
  • message: Optional. The status message at the top of the alert. Defaults to name of alert type.
  • message_file: Optional. The path to a file to use as message.
  • fail_if_message_file_missing: Optional. Will fail if message_file is set but the file is missing. Defaults to false.
  • color: Optional. The color of the notification bar as a hexadecimal. Defaults to the icon color of the alert type.
  • mode: Optional. The amount of information displayed in the message. See Modes. Defaults to normal_with_info.
  • disabled: Optional. This notification is disabled.
  • message_as_code: Optional. Message text will be wrapped in ``` [...] ```, if message is in mode normal or normal_with_info.

basic configuration:

jobs:
  plan:
  - put: notify

with an alert type, a mode and a message

jobs:
  plan:
  - put: notify
    params:
      message: my job failed
      mode: concise
      alert_type: failed

Alert Types

  • custom

  • success

  • failed

  • started

  • aborted

  • fixed

    Fixed is a special alert type that only alerts if the previous build did not succeed. Fixed requires username and password to be set for the resource if the pipeline is not public.

  • broke

    Broke is a special alert type that only alerts if the previous build succeed. Broke requires username and password to be set for the resource if the pipeline is not public.

Modes

Examples notifications with a messages with the different modes:

  • concise

  • normal

  • normal_with_info

concourse-slack-notifier's People

Contributors

dependabot-preview[bot] avatar dependabot-support avatar mergify[bot] avatar mockersf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

concourse-slack-notifier's Issues

Disable flag does not work

Hi @mockersf Thanks for this useful resource!

We noticed that the disable flag does not work properly. It returns true in should_send_message if the flag is set. I have a local fork and PR, but it seems upstream PRs are not enabled.

"unknown build" for build re-runs

In Concourse 6.0 you can now "re-run" a build. If you re-run build 314, for example, it will create a new build 314.1 consisting of the re-run. This Slack notification resource doesn't seem to like that and displays "unknown build" for these re-runs.

Screenshot:
image

To reproduce:

  1. Use Concourse >= 6.0
  2. Run a job that triggers a slack notification.
  3. Re-run that job using the rerun button or the fly CLI

Error: relative URL without a base

I'm getting the above error (relative URL without a base) when trying to set the url to something like (( slack-url )) which is stored in our credential backend.

Request: Docker image build trigger

Problem

Due to the planned expiration of Let's Encrypt's root certificate https://letsencrypt.org/docs/dst-root-ca-x3-expiration-september-2021/ slack formatted notifications do not work for servers with a leaf certificate provided by Let's Encrypt.

Concourse CI pipeline error

  | "error  sending request for url  (https://matrix.netresearch.de/appservice-webhooks/api/v1/matrix/hook/xxxxxx):  error trying to connect: error:14090086:SSL  routines:ssl3_get_server_certificate:certificate verify  failed:s3_clnt.c:1269: (certificate has expired)"
-- | --

Current certificate used in the Docker image

See the CN for the root certificate

/ # openssl s_client -servername matrix.netresearch.de -connect matrix.netresearch.de:443
CONNECTED(00000003)
depth=3 O = Digital Signature Trust Co., CN = DST Root CA X3
verify error:num=10:certificate has expired

Request

Is it possible for you to trigger a Docker image build and publish that to somewhere so we can continue using your great work?

"fixed" notification not working

The notifier is not sending "fixed" information to slack anymore.
It's hard to know the cause as the notifier is not providing enough information or logs to debug the issue.

The only thing present is the resource status: "Did not send Fixed notification to #xxx"

support providing CA/client certs to access concourse using https

api in resource https://github.com/concourse/docker-image-resource:

  • ca_certs: Optional. An array of objects with the following format:

    ca_certs:
    - domain: example.com:443
      cert: |
        -----BEGIN CERTIFICATE-----
        ...
        -----END CERTIFICATE-----
    - domain: 10.244.6.2:443
      cert: |
        -----BEGIN CERTIFICATE-----
        ...
        -----END CERTIFICATE-----

    Each entry specifies the x509 CA certificate for the trusted docker registry
    residing at the specified domain. This is used to validate the certificate of
    the docker registry when the registry's certificate is signed by a custom
    authority (or itself).

    The domain should match the first component of repository, including the
    port. If the registry specified in repository does not use a custom cert,
    adding ca_certs will break the check script. This option is overridden by
    entries in insecure_registries with the same address or a matching CIDR.

  • client_certs: Optional. An array of objects with the following format:

    client_certs:
    - domain: example.com:443
      cert: |
        -----BEGIN CERTIFICATE-----
        ...
        -----END CERTIFICATE-----
      key: |
        -----BEGIN RSA PRIVATE KEY-----
        ...
        -----END RSA PRIVATE KEY-----
    - domain: 10.244.6.2:443
      cert: |
        -----BEGIN CERTIFICATE-----
        ...
        -----END CERTIFICATE-----
      key: |
        -----BEGIN RSA PRIVATE KEY-----
        ...
        -----END RSA PRIVATE KEY-----

    Each entry specifies the x509 certificate and key to use for authenticating
    against the docker registry residing at the specified domain. The domain
    should match the first component of repository, including the port.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.