How Can We Help?

Search for answers or browse our knowledge base.

Recent Comments






      SyncNow logo SyncNow – connect teams , tools and processes

      Update Entities with SonarQube Quailty

      < All Topics


      With SyncNow Quality Gate information can be publish to work systems. SyncNow DevOps Gate works with SonarQube webhookd and publishes quality code scan information to entities in target system.

      The following article elaborates the process of Setting Sonarqube webhook and with Jenkins as an example for publishing information with custom parameters to target systems

      Usage Examples

      Publish Quality of code to work systems features , epics mentioned in code

      1. Update Sonarqube status to entities mentioned in comments
      2. Add Sonarqube status and link in comments of entities mentioned in comments
      3. Link Soarqube report url to entities mentioned in comments
      Jira Example of an entity updated with Sonarqube information
      Jira Example of an entity updated with Sonarqube information into comments

      Step By Step Instructions

      Create Sonaeqube connector

      1. Create a DevOps Gate process for SonarQube Scan Status with configuration like on images below
      1. Set map for SonarQube virtual entity which represent SonarQube data to an entity in target system, map can be different for every entity type
      2. Map the fields from SonarQube information to entity fields
      1. Go to the Configuration page and press the Create | Update an Entity button. Copy the WebHook URL.

      Create an entity in target system the URL should be


      To Update and entity the URL should be


      To add a comment with sonarqube link The URL Should be in the following format


      To link SonarQube URL to an entity

      1. Go to the SonarQube system. Navigate to Administration -> Configuration -> WebHooks page
      1. In a dialog that appeared paste a WebHook URL (step 2 in this tutorial);
      2. Press the Create button
      3. Security : It is highly commended to add a secret for communicating with SyncNow

      7. Set Security parameters in SyncNow System connector UI

      1. Add sonarqube parameters from Jenkins script, parameters can be custom defined, custom parameters should correspond to field mapping in DevOpsgate process entity mapping
      def getCommentsString() {
          def list = []
          def changeLogSets = currentBuild.changeSets               
          for (int i = 0; i < changeLogSets.size(); i++) {
              def entries = changeLogSets[i].items
              for (int j = 0; j < entries.length; j++) {
                  def entry = entries[j]
                  if (entry.msg != null) {
                     list.add("""${entry.commitId} on ${new Date(entry.timestamp)}: ${entry.msg.replaceAll("[\n\r]", " ")}""")
          return list.join(',') 
      pipeline { 
          agent any
          stages {
              stage("SonarQube Analysis") {            
                  steps {
                               def commits = getCommentsString() 
                               def scannerHome = tool 'main_sonar_scanner';
                               withSonarQubeEnv('sonarmain') {
                                     sh """${scannerHome}/bin/sonar-scanner -Dsonar.analysis.param.Param1='Sonar Quality Tests for Build ${JOB_NAME}' -Dsonar.analysis.param.Param4='${env.VERSION}.${env.BUILD_ID}' -Dsonar.analysis.targetDetail.Project=<TargetSystemProjectKey>
      -Dsonar.analysis.targetDetail.CommitComments='${commits}' -Dsonar.analysis.targetDetail.EventRelativeURL='/job/${JOB_NAME}/${env.BUILD_ID}' -Dsonar.analysis.targetDetail.CommentLinkTitle='SonarQube Report' """
      1. Verify that the script is running and data is published to SyncNow
      Was this article helpful?
      0 out of 5 stars
      5 Stars 0%
      4 Stars 0%
      3 Stars 0%
      2 Stars 0%
      1 Stars 0%
      How can we improve this article?
      Please submit the reason for your vote so that we can improve the article.
      Table of Contents
      Skip to content