Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

Post Test Lab Results to Slack channel

This sample demonstrates how to post to a Slack channel in response to the completion of a test matrix in Firebase Test Lab. The message will look like this:

example Slack message with Test Lab status

Setting up the sample

  1. Create a Slack app

  2. Visit Slack's Your Apps page, select your app, and click OAuth & Permissions on the left side of the page.

    1. Under the Scopes header, type in chat:write:bot and add the scope to your app. Click Save Changes

    2. Under the OAuth Tokens & Redirect URLs header, click the Install App button. Once you've installed the app to your Workspace and you're returned to the page with OAuth Tokens & Redirect URLs, copy the OAuth Access Token that was automatically created when your app was installed. You'll need this later so your function can authenticate with Slack.

  3. Get the ID of the channel you want your Slack app to post to. You'll need this later so your function can post to the correct channel.

  4. Clone or download this repo and open this directory in a terminal:

    cd testlab-to-slack
  5. You must have the latest Firebase CLI installed. If you don't have it, install it with npm install -g firebase-tools and then sign in with firebase login.

  6. Configure the CLI locally by using firebase use --add and select your project in the list.

  7. Install Cloud Functions dependencies locally by running: cd functions; npm install; cd -

  8. Set the following environment variables so that the function can authenticate with Slack and post to the correct room:

    firebase functions:config:set slack.token="YOUR_SLACK_OAUTH_TOKEN" slack.channelid="ID_OF_YOUR_SLACK_CHANNEL"
    

Deploy and test

This sample comes with a web-based UI for testing the function. To test it out:

  1. Deploy your function using firebase deploy --only functions
  2. Navigate to the Test Lab section of the Firebase Console and start a test.
  3. Once the test finishes running, check your Slack channel and view the new post!