[SOLVED] Sonarqube PR Analysis is working but GitHub PR Check is not happening

Sonarqube Version: 7.9.1 Developer Edition - latest version
Java: Redhat OpenJDK 11
GitHub Enterprise version 2.15
Sonar scanner version: 3.3

The scan and analysis is happening as expected. The only thing we are seeing is the decoration of the PR is not happening at all. When Sonarqube was in Trace log we saw the below log entries:

2019.07.22 20:11:55 DEBUG ce[AWwbGOeqf_exK80zuTOH][c.s.C.A.C.A.A.D] GET response did not have expected HTTP code (was 401): {"message":"'Issued at' claim ('iat') must be an Integer representing the time that the assertion was issued","documentation_url":"https://developer.github.com/enterprise/2.15/v3"}
2019.07.22 20:11:55 TRACE ce[AWwbGOeqf_exK80zuTOH][sql] time=1ms | sql=insert into ce_task_message ( uuid, task_uuid, message, created_at ) values ( ?, ?, ?, ? ) | params=AWwbGPM1pulh-2K9ftK1, AWwbGOeqf_exK80zuTOH, Pull request decoration did not happen. Please install SonarQube Github application on the repository's organization or user., 1563822715701

Remediation steps tried:

  • Re-install GitHub Application on Organisation - no change
  • Regenerate Private key - no change
  • Enter invalid Private key - error caused with invalid key (putting it back same no decoration but no error)
  • Re-configured Pull Request settings and re setup application properties - different errors but no success on decorations

What have we set in SonarQube Administration → Pull Request tab

  • sonar.pullrequest.provider = GitHub
  • sonar.pullrequest.github.endpoint = https://our-company-url/api/v3
  • sonar.alm.github.app.name = SonarQubePRChecks
  • sonar.alm.github.app.id = XX
  • sonar.alm.github.app.privateKeyContent.secured = Key created by SonarQube app on GitHub

Sonar.properties are as follows:

  • sonar.projectKey=organisation:repo-name
  • sonar.projectName=repo-name
  • sonar.sourceEncoding=UTF-8
  • sonar.sources=pom.xml, src/main
  • sonar.projectVersion=x.y.0-PRZZ
  • sonar.projectBaseDir=jenkins-folder-patg
  • sonar.tests=src/test/java
  • sonar.java.binaries=target/classes/**
  • sonar.pullrequest.branch=branch-name
  • sonar.pullrequest.key=123 (github pull request number
  • sonar.pullrequest.base=master
  • sonar.pullrequest.github.repository=orgainsation/repo-name
  • sonar.verbose=true
  • sonar.issuesReport.console.enable=true

This is a new one!

A quick google search implies this error could have something to do with the date/time on your SonarQube server being “off” (ahead/behind/skewed in some way). I would start by taking a look to see if that’s the case.

Thanks for the quick response.
So I will check tomorrow to see if our servers (SonarQube and GitHub) has time set up correctly to an NTP server.

It definitely looks correct (it says the current time) it is set to British Summer Time (BST). Our GitHub server is set to UTC though. Could the BST vs UTC be that error cause?

NTP wasn’t set up on either Jenkins or SonarQube which may mean there was a time drift. Applying this today. Will update if the issues is resolved (GitHub appliance had NTP correctly configured)

1 Like

So I set it up on Sonarqube and now it is working as expected (the time had drifted on SonarQube).
Also applied NTP to the entire Jenkins estate to insure there are no issues there as well.

It is now working

:tada: Glad it’s working for you, and now I can tuck this tidbit away for future reference (or maybe something in the docs!)

@karl.parry @Colin
We are getting the same error GET response did not have expected HTTP code (was 401): {“message”:"‘Issued at’ claim (‘iat’) must be an Integer representing the time that the assertion was issued",“documentation_url”:“https://developer.github.com/v3”

Can you please help us with it?
We are using github api not enterprise.

Juliana,

Did you read through this thread? What do you think about the way Karl solved it?

Colin

1 Like

@Colin @karl.parry

I am getting the same error.
Can you explain how you configured Jenkins and Sonarqube?

Jenkins : on Windows Server 2016
SonarQube : on Ubuntu 18.04

thx.