Pull Request analysis is broken after renaming a repo on GitHub

We have an analyzed project which was imported from github with PR decoration configured. We renamed the repository on github and changed both the sonar.pullrequest.github.repository variable which we provide to gradle for analysis and also the same property in the administration of the project. All PR analysis jobs end with a warning saying “Pull request decoration did not happen. Please install SonarCloud Github application on the repository’s organization or user.”. SonarCloud github app is authorized to access that repository without any doubt.

Also the github icon next to the project name has the old wrong URL on it.

So, what should we do?

This is a private repo. So it’s not visible from the outside. In case a support representative reads this the URL is https://sonarcloud.io/dashboard?id=banqr-io_banqr-apis

Any feedback on this?
I also raised an internal ticket. Still don’t have a response.

Hi @yervand,

Currently, SonarCloud does not rename automatically or does not have a functionality to rename repository.
From what I tested, GitHub does a redirect when renaming the repository, and in some cases PR analysis is possible after a renaming without having to change the sonar.pullrequest.github.repository.

One solution would be to delete your SonarCloud project and reimporting it.

If you cannot, could you specify :

  • What CI do you use
  • If your SonarCloud app on GitHub has granted access to All repositories or selected repositories

Also you said

What administration of the project are you referring to?

Thanks,
Aurelie.

The access is there and SonarCloud can actually “see” all repositories. What does the “and in some cases PR analysis is possible after a renaming without having to change the sonar.pullrequest.github.repository” mean? How can I do a rename?
I need the PR decoration to work and I don’t want to lose the history of the repository. My issue is that on PR decoration I’m getting this error message "Pull request decoration did not happen. Please install SonarCloud Github application on the repository’s organization or user.”

HI @yervand,

I did a test where I renamed the GH repo and launched several PR analysis manually without changing the analysis parameters, and it worked.

How do you launch the analysis?

These are the arguments we use, the variables are mostly populated by Jenkins.

// If this is a pull request analysis supply necessary parameters to sonar
' -Dsonar.projectKey=banqr-io_banqr-banqr-apis' +
' -Dsonar.organization=banqr-io' +
' -Dsonar.host.url=https://sonarcloud.io' +
' -Dsonar.login=' + SONAR_KEY
' -Dsonar.pullrequest.base=' + CHANGE_TARGET +
' -Dsonar.pullrequest.branch=' + CHANGE_BRANCH +
' -Dsonar.pullrequest.key=' + CHANGE_ID +
' -Dsonar.pullrequest.provider=GitHub' +
' -Dsonar.pullrequest.github.repository=banqr-io/banqr-apis'

This is still broken. Please, can someone look into this?

Sorry about the delay, I will take a closer look later today and get back to you.

Hi @yervand,

So far I’m not able to reproduce this issue: given a repo renamed on GitHub, PR decoration works for me with both the old and the new repo names. (Passed at the time of running the PR analysis on the command line with -Dsonar.pullrequest.github.repository=old_or_new_name)

I will investigate further to see things might be different for your case. In the meantime:

  • You mentioned the link in the SonarCloud UI is wrong, it’s still pointing to the old wrong URL. If you click on it, does GitHub redirect you to the correct one?
  • Can you please run a new PR analysis on this repo? (Just so that I can find some fresh logs.)

Thanks,
Janos

Janos, thanks for looking into this.

  1. When I click on the Icon with the wrong URL I get automatically redirected to the correct page by github.
  2. a PR analysis I did 5 minutes ago. https://sonarcloud.io/dashboard?id=banqr-io_banqr-apis&pullRequest=241

The command line option I have is: -Dsonar.github.repository=banqr-io/banqr-apis

I found the problem: GitHub doesn’t redirect requests for renamed private projects, only for public. And since we don’t support yet the renaming in GitHub bindings, the only way to fix this is by a manual database update in our side. I put in a request for this, I’ll get back to you when it’s done.

I created a ticket to track this issue: https://jira.sonarsource.com/browse/SCCOMM-4

@yervand We’ve completed the database update. This should fix the PR decoration in your next analyses (as well as the link of the icon). Can you please confirm that your problem is solved now?

@janos thank you very much! The analysis is working as expected!
There is, however another issue, I need to rename another repository. What should I do? Are you going to fix this issue permanently in the upcoming future? If so, then I can wait.

Thanks @yervand for confirming the manual fix!

I don’t have a time frame for the proper support of renaming GitHub repos. It’s going to be quite painful for us to apply manual fixes on a case-by-case basis, so that will surely be a strong motivator.

You can track the state of the fix with the ticket I linked earlier. When you would like another rename and the ticket is not closed yet, ping me back here, and I will open a private thread to get the necessary details (SC project ID, old URL, new URL).

Hi @yervand ,

We now support the renaming of private GitHub repos!

Tom

Wow! thank you for letting me know!