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:
-
Visit Slack's Your Apps page, select your app, and click OAuth & Permissions on the left side of the page.
-
Under the Scopes header, type in
chat:write:botand add the scope to your app. Click Save Changes -
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.
-
-
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.
-
Clone or download this repo and open this directory in a terminal:
cd testlab-to-slack -
You must have the latest Firebase CLI installed. If you don't have it, install it with
npm install -g firebase-toolsand then sign in withfirebase login. -
Configure the CLI locally by using
firebase use --addand select your project in the list. -
Install Cloud Functions dependencies locally by running:
cd functions; npm install; cd - -
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"
This sample comes with a web-based UI for testing the function. To test it out:
- Deploy your function using
firebase deploy --only functions - Navigate to the Test Lab section of the Firebase Console and start a test.
- Once the test finishes running, check your Slack channel and view the new post!
