Giter Site home page Giter Site logo

iress / junit-slack-notification-buildkite-plugin Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 220 KB

๐Ÿ“ˆ Summarise your test success, failures and ignored as a slack message

License: MIT License

Shell 11.62% JavaScript 0.35% Makefile 0.39% TypeScript 87.65%
buildkite buildkite-plugin junit slack-bot tests

junit-slack-notification-buildkite-plugin's Introduction

JUnit - Slack notification buildkite plugin

Use "JUnit XML report" to generate Slack notification from Buildkite

This plugin was inspired by junit-annotate-buildkite-plugin which also retrieve JUnit XML reports and process them.

Example

Add an extra step like this after running your tests to your pipeline.yml:

steps:
  - label: Run tests
    key: my-test
    command: ...
    
  - label: ":slack: :memo: to #junit_bot_testing"
    depends_on: my-test
    allow_dependency_failure: true
    plugins:
      - iress/junit-slack-notification#v1.0.6:
          artifacts: "**/*.xml"
          SLACK_TOKEN: "xoxb-xxxxxxxxxxx-xxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxx"
          SLACK_CHANNEL: "#junit_bot_testing"

or

steps:
  - label: Run unit tests
    key: my-unit-test
    command: ...
  - label: Run Verification tests
    key: my-verification-test
    command: ...
    
  - label: ":slack: :memo: to #junit_bot_testing"
    depends_on: my-test
    allow_dependency_failure: true
    plugins:
      - iress/junit-slack-notification#v1.0.6:
          test_suites:
              - name: "Unit tests"
                artifacts: "unit-test/**/*.xml"
              - name: "Verification tests"
                artifacts: "verification-test/**/*.xml"
          SLACK_TOKEN: "xoxb-xxxxxxxxxxx-xxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxx"
          SLACK_CHANNEL: "#junit_bot_testing"

Configuration

artifacts (Use if no test_suites, string, default **/*.xml )

The file pattern to use to retrieve JUnit XML reports

test_suites (object)

The object containing the JUnit XML reports. The object should be in the following format:

test_suites:
  - name: "Test Suite 1"
    artifacts: "test-suite-1/**/*.xml"
  - name: "Test Suite 2"
    artifacts: "test-suite-1/**/*.xml"

SLACK_CHANNEL (Required, string)

Name of the public Slack channel which your bot will report e.g. #junit_bot_testing

SLACK_TOKEN_ENV_NAME (String)

Name of the environment variable that contains the Slack API token. Default value: "SLACK_TOKEN"

SLACK_TOKEN (string)

The token of your Slack application which is allows chatting on your Slack organisation.

DOCKER_CACHE (string)

If you which to use a Docker registry proxy, specify the path prefix here

EXTRA_SLACK_MESSAGE (string)

Contains an extra message to add on the bottom of the generated message. You can include a variable using the syntax {var}.

EXTRA_SLACK_MESSAGE: "This project has a libyear of {LIBYEAR_DRIFT}"

with LIBYEAR_DRIFT environment variable set to 0.5 will add the message This project has a libyear of 0.5

Create a bot for your workspace.

See Slack documentation Create a bot for your workspace for instruction to create a Slack application.

Here a sample of your slack application manifest sample. Make sure the scope of your bot is allowed to chat:write & chat:write:public

_metadata:
  major_version: 1
  minor_version: 0
display_information:
  name: JUnit Summary Bot
  description: JUnit run summary information
  background_color: "#000000"
features:
  bot_user:
    display_name: JUnit Summary Bot
    always_online: false
oauth_config:
  scopes:
    bot:
      - chat:write
      - chat:write.public
settings:
  org_deploy_enabled: false
  socket_mode_enabled: false
  token_rotation_enabled: false

Developing

To start development, install dependency package and compile typescript

npm install
npm run build

To run unit tests in Jest

npm run test

Contributing

  1. Fork the repo
  2. Make the changes
  3. Run the tests
  4. Commit and push your changes
  5. Send a pull request

Licence

MIT License (See the included Licence file for more information).

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.