The Sonar Microsoft Teams Notifier is a SonarQube plugin that seamlessly sends SonarQube analysis results to Microsoft Teams, enhancing code quality insights and promoting better collaboration among development teams. With this plugin, you can receive real-time notifications about your project's code quality directly in your Microsoft Teams channels.
- Automated Notifications: Receive automated notifications in your Microsoft Teams channels whenever a SonarQube analysis is completed for your project.
Before setting up the Sonar Microsoft Teams Notifier plugin, make sure you have set up the incoming webhook in your Microsoft Teams channel by following the guide provided in the Microsoft Teams documentation.
To set up the Sonar Microsoft Teams Notifier plugin, follow these steps:
-
Download the Plugin: Obtain the latest release of the plugin JAR file from the Releases page of this repository.
-
Copy JAR to Extensions Directory: Copy the downloaded JAR file of the Sonar Microsoft Teams Notifier plugin to the
extensions/plugins
directory of your SonarQube installation. -
Restart SonarQube: Restart your SonarQube server to load the newly added plugin.
If you want to build the plugin from source and test your changes locally, follow these steps:
-
Clone the Repository: Clone the repository to your local machine.
-
Build the Plugin: Navigate to the root directory of the cloned repository and build the plugin using the provided build tool (e.g., Maven). Run the appropriate command:
# For Maven mvn clean package
-
Copy JAR to Extensions Directory: After building the plugin, locate the JAR file in the
target
directory (created during the build process). Copy the JAR file to theextensions/plugins
directory of your SonarQube installation. -
Restart SonarQube: Restart your SonarQube server to load the newly built plugin.
You can configure the plugin either through the SonarQube configuration UI or using the Sonar Scanner command-line tool.
-
Log in to your SonarQube server as an administrator.
-
Navigate to Administration > Configuration.
-
Locate the Sonar Microsoft Teams Notifier section.
-
Configure the following options:
- Enable Plugin: Set the value of
sonar.notify.microsoft.team.enable
totrue
to enable the plugin. - Webhook URL: Set the value of
sonar.notify.microsoft.team.webhook.url
to the Microsoft Teams webhook URL where you want to receive notifications. - Webhook Message Avatar: Set the value of
sonar.notify.microsoft.team.webhook.avatar
to the URL of the avatar image you want to use for the notifications. - Webhook Send On Failed: Set the value of
sonar.notify.webhook.fail.only.enable
to enable send notify when analysis failed
- Enable Plugin: Set the value of
-
Save the configuration.
When running the Sonar Scanner command, you can provide the configuration options as command-line parameters:
Example command:
mvn clean verify sonar:sonar -Dsonar.notify.microsoft.team.enable=true -Dsonar.notify.webhook.fail.only.enable=true -Dsonar.notify.microsoft.team.webhook.url=<your-webhook-url> -Dsonar.notify.microsoft.team.webhook.avatar=<avatar-url>
Example sonar-project.properties
sonar.notify.microsoft.team.enable=true
sonar.notify.microsoft.team.webhook.url=<your-webhook-url>
sonar.notify.microsoft.team.webhook.avatar=<avatar-url>
sonar.notify.webhook.fail.only.enable=true
Replace <your-webhook-url>
with your actual Microsoft Teams webhook URL and <avatar-url>
with the URL of the avatar image.
-
Run a SonarQube analysis on a project to trigger the notifications.
-
Check your Microsoft Teams channel for the automated notifications containing the SonarQube analysis results.
Your feedback and contributions to the Sonar Microsoft Teams Notifier plugin are highly appreciated! If you encounter any issues, have suggestions for improvements, or would like to contribute to the project, please feel free to open an issue or create a pull request.
This plugin is distributed under the Apache License 2.0.
Disclaimer: This plugin is not officially endorsed or supported by SonarQube or Microsoft. Use it at your own discretion.