GitHub-Sonarqube-Jenkins PR decoration

PR decoration in GitHub-Jenkins pipeline(single-branch) it’s not working. It’s just commenting the URL of the SonarQube in the pull request. The code I attached below for your reference

 stage('Send report to GitHub PR') {
            steps {
                script {
                    def prNumber = 2
                    def githubPrComment = sh(script: """
                        curl -H 'Authorization: token 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' -X POST -d '{"body":"[SonarQube Analysis Report](${SONARQUBE_URL})"}' https://api.github.com/repos/msdvc-sandbox1/new-repo/issues/$prNumber/comments
                    """, returnStatus: true)
                    if (githubPrComment == 0) {
                        echo 'SonarQube analysis report sent to GitHub PR successfully'
                    } else {
                        error 'Failed to send SonarQube analysis report to GitHub PR'
                    }
                }
            }
        }

the report i am getting while executing the pipeline is attached below

Any leads would be helpful. If anyone set the Jenkins(single branch pipeline)-GitHub PR Decoration set-up. Please let me know where i am missing?

Hi,

First, I assume you’ve already revoked the token you just published to the internet?

Regarding your pipeline code… it seems to be doing what you’ve scripted?

And that’s not SonarQube PR decoration. That’s driven server-side.

What’s your SonarQube version and edition? You can find them in the footer if you’re not sure.

 
Ann

Hey, There is a document for pr decoration using multibranch pipeline.is there any way we can achieve this in normal pipeline in Jenkins? If it is then please share me the link. I have surfed all through the internet didn’t find it.

Or if any web API that displays exactly like a pr decoration like
Bugs-0
vulnerabilties-1
code smell-0
coverage-0
Duplications-1
I have tried many web API’s but none of this come like this. Please this a high priority task any lead would much helpful Ann Campbell

Hi,

You may find the Jenkins extension docs helpful.

And again:

 
Ann

  • Enterprise Edition
  • Version 10.2.1

Hi,

Thanks for those details.

Since you’re on a current, commercial version, the functionality is available to you. You just need to configure it properly. I urge you to review the docs I linked earlier, and perhaps also these.

 
Ann

Hi,

This time I have configured it perfectly. but in the analysis warnings i have got error like this ''Failed to report status to DevOps platform because the configured repository slug does not have the expected format ‘organization/repository’ " , But the DevOps platform integration shows configuration is valid I attached the screenshot for your reference

Hi Ann,

It’s working perfectly. I have successfully configured it. Thanks for all your support. Please do support budding software dudes.

1 Like