Giter Club home page Giter Club logo

jenkins-google-chat-notification's Introduction

Jenkins Test Results Notification (work in progress!)

This repository can be used as a Shared Library by Jenkins. It implements different steps to be used in a Jenkins Pipeline to send messages to Google Chat Service Groups.

Setup

  1. Add this repository to your Jenkins Global Pipeline Libraries as described here.
  2. Make sure that the HTTP Request Plugin is installed on your Jenkins. This library relies on it to send messages to Google Chat Service
  3. Use the library in your Jenkinsfile. Either check load implicitly or using a @Library annotation (see Using Libraries for details).
  4. Configure a Webhook in your Google Chat Room and copy the URL.
  5. In your Jenkinsfile either set an environment variable and assign the URL to it.
    If you name that variable GOOGLE_CHAT_URL, it will be used automatically by the steps of this library, otherwise you will need to pass it as a parameter, which might be useful to send messages to different Groups.
    Note that anyone knowing the URL will be able to send messages via your Webhook, so you should configure the URL as a secret text in your Jenkins' credentials section to keep it out of you version control and the Jenkins logs. See Using Credentials.
  6. Use the steps as described below.

Steps

sendGoogleChat

This step can be used to send Simple Messages. It takes the message as its only mandatory parameter. As a second parameter you can pass the Webhook URL or you can define it in an environment variable named GOOGLE_CHAT_URL.

Parameters

  • String message (mandatory): The text message to be sent. You can use any formatting as described here.
  • String url (optional): the Google Chat Webhook URL to be used. Needs to be defined, if env.GOOGLE_CHAT_URL is not set!``

Example

sendGoogleChat("This is a _simple_ text message " +
    "with a <https://github.com/mkutz/jenkins-google-chat-notification|link>" +
    "\nand a line break, " +
    "which might be interesting to <users/all> users in the Group.")

Image of the example simple message in Google Chat

sendGoogleChatBuildReport

This step sends a bunch of data about the build as a Card Message.

Parameters

  • Map<String, String> buildProperties (optional): adds the given data as KeyValue Widgets to the Card Message. If there is a key message it will be added as a Text Paragraph Widget instead.
  • String url (optional): the Google Chat Webhook URL to be used. Needs to be defined, if env.GOOGLE_CHAT_URL is not set!``

Example

sendGoogleChatBuildReport(Version: env.VERSION,
    message: "This is a <strike>simple</strike> <i>card<i> text message " +
                 "with a <a href=\"https://github.com/mkutz/jenkins-google-chat-notification\">link</a>" +
                 "<br>and a line break, " +
                 "which does not support mention @all users in the Group.")

Image of the build report message in Google Chat

jenkins-google-chat-notification's People

Contributors

mkutz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

jenkins-google-chat-notification's Issues

Secured HTTP mandatory ?

Hello,
Link url (href) in the button (BUILD, CONSOLE,...) are transformed to "https://" instead of http://
Possible to keep unsecured http link ?

Unable to send Multiple Properties apart from Version

I need to send few details as part of the chat message properties. By default in your example I can see Version being sent. But when I add new properties, I am getting groovy.lang.MissingPropertyException: No such property: <property name> for class: groovy.lang.Binding

Can you guide how to send multiple properties ?

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.