Notifications

CodeScene comes with a flexible notification system which you can use to receive notification messages when a CodeScene analysis is run.

You can see an example of a Slack notification message in Fig. 180.

Slack notification message example

Default notifications start with a project name and the analysis results link. Then comes the list of analysis warnings (if any).

You can customize the content of notification messages in the CodeScene configuration.

Generic Configuration

CodeScene administrators can customize notifications in the global configuration on the Notifications tab.

Here’s an example:

Example of notification templates config

CodeScene host URL must be configured properly if you want to receive proper links to your analyses’ results. Make sure that the protocol, the host and the port are all correct.

There are two subsections in the Notifications Configuration:

  1. Notification Templates - generic notification templates for the actual message that will be sent
  2. Slack Notifications - Slack-specific configuration settings

Notification Templates

These are generic notification templates which define the content of notification messages.

You can see a typical example of a notification template in Fig. 181.

  • Analysis result is a special type of notification template which is only used to add the analysis result link to all other notifications.
  • Analysis success is a simple notification that is sent whenever an analysis is run - it’s turned off by default to avoid noisy notifications.
  • Analysis error is only sent when an analysis fails with an unrecoverable error.
  • Rising Hotspot warning is an example of a notification which is sent when your analysis finishes with “Rising Hotspot” warning.

Template Variables

You can use several variables in your notification templates. You use them by wrapping them with double curly braces, e.g. {{notification/display-name}}.

The following variables are available:

  • project-name - the name of the project
  • project-url - an absolute URL to the project details; can be useful when the analysis fails
  • analysis-result-url - an absolute URL to the project analysis results
  • notification/display-name - a display name of the notification, e.g. Rising Hotpost warning; it’s mostly useful for warnings and corresponds to the labels used for notification templates in configuration.
  • notification/description - a short description of each notification; again, mostly useful for warnings and visible under the notification labels in configuration.

Slack Notifications

Slack Notifications configuration are separate from the generic notification settings.

They are hidden by default so you need to enable them first:

Collapsed Slack Notifications config

Slack Application Setup

Before starting, you need to set up your Slack application. Click the Create a Slack app button and fill in the details. When the application is created, select OAuth & Permissions in the left panel and pick the chat:write:bot permission in the Select Permissions Scopes combo box. Save your changes and then click the Install App to Workspace button at the top of the page:

Slack application setup

After the Slack application is installed you should be able to get your access token:

Access token after Slack application is installed

Copy and paste this token into the CodeScene Slack configuration.

Slack Notifications Config

Slack Notifications configuration comes down to the two important things:

  • Notification recipient - the name of the channel (of the user) where the notifications should be sent
  • Slack API token - the access token created in the previous step

Note: for Notification recipient, use the name of the Slack channel, as is, e.g. codescene-slack. If you want to send notifications to the specific user, then prepend @ to the username, .g. @juraj.martinka for sending notifications to the slack user juraj.martinka.

You can see a sample configuration in Fig. 185.

Slack Notifications config expanded

Once you have everything configured click Save Slack Notifications Settings.

You are ready to run an analysis and recieve your first notification!