How can I receive notifications for the following below items

I need to receive notifications for the following items: all result for my projects and Failed background tasks for projects to Specific users.

how can I setting ? I am no idea for it.

Hi,

Welcome to the community!

Unfortunately, this is beyond our scope.

 
Ann

hi , Any functions setting or plugins can realize it?

Welcome :slight_smile:

not sure if it’s that what you’re looking for
You may subscribe to notification mails for specific events here
https://<yoursonarhost>/account/notifications

either global = overall or for specific projects

Gilbert

hi ,
I saw that setting, but it seems that just mail when false analyzed or new issues

I want to show the analyzed for all results(both success and false and all issue) in the email

Ok, in case of success you will have no issues.
Failed is handled by Sonarqube user setting, for success you have these options

  1. send a mail from your ci/cd pipeline, i.e. the Jenkins/workspace/yourjob/.sonar/report-task.txt has the
    dashboard url for the project
  2. use a reporting plugin like
    commercial Our SonarQube and SonarCloud plugins and products | bitegarden - Plugins for SonarQube and SonarCloud
    free GitHub - cnescatlab/sonar-cnes-report: Generates analysis reports from SonarQube web API.
    compatible with Sonarqube LTS, works with latest but ui glitches
    and make use of their rest api
  3. use Sonarqube webhooks and write your own webhook consumer, i.e. with Spring

1. Set up a Spring Boot project

Create a new Spring Boot project using your preferred IDE or the Spring Initializr (https://start.spring.io/). Select the following dependencies:

  • Spring Web
  • Spring Boot DevTools (optional, for hot reloading during development)

2. Create a controller to handle the webhook

Create a new controller class and define a method to handle the incoming webhook request from SonarQube. For example:

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SonarQubeWebhookController {

    @PostMapping("/sonarqube-webhook")
    public ResponseEntity<String> handleSonarQubeWebhook(
            @RequestBody String payload,
            @RequestHeader("X-Sonar-Webhook-HMAC-SHA256") String hmacSha256) {

        // Verify the HMAC signature (optional)
        // boolean isValidSignature = verifyHmacSignature(payload, hmacSha256);

        // Process the payload
        processSonarQubeWebhookPayload(payload);

        return ResponseEntity.ok("Webhook received");
    }

    private void processSonarQubeWebhookPayload(String payload) {
        // Parse the payload and perform desired actions
        // (e.g., update database, trigger notifications, etc.)
        System.out.println("Received SonarQube webhook payload: " + payload);
    }

    // Implement HMAC signature verification logic if needed
    private boolean verifyHmacSignature(String payload, String hmacSha256) {
        // ...
        return true; // or false based on verification result
    }
}

In this example, the handleSonarQubeWebhook method accepts the webhook payload in the request body and the HMAC-SHA256 signature in the X-Sonar-Webhook-HMAC-SHA256 header (if configured in SonarQube). You can implement the verifyHmacSignature method to verify the signature if needed.

The processSonarQubeWebhookPayload method is where you can parse the payload and perform desired actions based on the received data.

3. Configure SonarQube webhook

In the SonarQube administration interface, navigate to the “Webhooks” section and create a new webhook. Provide the URL of your Spring application’s endpoint (e.g., https://your-app.com/sonarqube-webhook) and configure any necessary authentication details (e.g., HMAC secret).

4. Run the Spring Boot application

Run the Spring Boot application, and it will start listening for incoming webhook requests from SonarQube on the configured endpoint.

With this setup, your Spring application will be able to consume and process the SonarQube webhook payloads. You can enhance the application further by implementing additional features like sending notifications (mail, slack …) authentication, payload validation, error handling, and integration with other components or services as per your requirements.