Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backstage sonarqube integration - "No project with key exist" #1471

Open
2 tasks done
somyabhatia opened this issue Oct 1, 2024 · 5 comments
Open
2 tasks done

Backstage sonarqube integration - "No project with key exist" #1471

somyabhatia opened this issue Oct 1, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@somyabhatia
Copy link

📜 Description

I have been trying to integrate backstage with sonarqube . I have tried the instruction given on https://roadie.io/backstage/plugins/sonarqube/ and also tried https://github.com/backstage/community-plugins/blob/main/workspaces/sonarqube/plugins/sonarqube-backend/README.md . But nothing is working. I am getting "no project with key exists. In token/api I am sending token generated from administration tab. I have tried project token and user token (squ..., and sqp...). Can anyone please tell me exact config , suposing that my sonarqube instance is https://test.sonar.net/sonarqube.

To debug the issue, in Postman I hit API [https://test.sonar.net/sonarqube/api/components/search?qualifiers=TRK&componentKeys=test:projectKey"] . With project token it gives me correct result but with usertoken it gives me 401 unauthorized, (though I have created user token using admin account). Also, in Postman when I hit the same api via backstage host like https://<backstage_host>/api/sonarqube/components/search?qualifiers=TRK&componentKeys=test:projectKey , then it return html which is loging page of my backstage host.

👍 Expected behavior

image

👎 Actual Behavior with Screenshots

image

👟 Reproduction steps

Added config in app-config and added annotation with project key in the catalog-info

📃 Provide the context for the Bug.

No response

🖥️ Your Environment

No response

👀 Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Are you willing to submit PR?

None

@somyabhatia somyabhatia added the bug Something isn't working label Oct 1, 2024
@benjdlambert benjdlambert transferred this issue from backstage/backstage Oct 3, 2024
@punkle
Copy link
Contributor

punkle commented Oct 7, 2024

then it return html which is loging page of my backstage host

Can I ask if other parts of the API are returning correct responses? Are you using a proxy or the sonarqube backend. If you are using the proxy, you may need to set the following setting to the internal url of the backend api.

sonarQube:
  baseUrl: https://your.sonarqube.instance.com

@vinzscam
Copy link
Member

vinzscam commented Oct 8, 2024

can you also share the annotation you have set in the entity?

Please double check that the annotation is in one of the following format:

      // Examples:
      //   instanceA/projectA  -> projectInstance = "instanceA" & projectKey = "projectA"
      //   instanceA/tenantA:projectA -> projectInstance = "instanceA" & projectKey = "tenantA:projectA"
      //   instanceA/tenantA/projectA -> projectInstance = "instanceA" & projectKey = "tenantA/projectA"

@somyabhatia
Copy link
Author

@vinzscam

The annotation I am using is:
sonarqube.org/project-key: "" as suggested in the document.

Can you please tell me with example what exactly should come in tenantA or projectA or what is instanceA in instanceA/projectA -> projectInstance = "instanceA" & projectKey = "projectA".
I have defined instanceA in app-config as given below but it not work for me:

sonarqube:
instances:
- name: default
baseUrl:
apiKey: squ_......

@somyabhatia
Copy link
Author

@punkle

Can I ask if other parts of the API are returning correct responses? : Can you please explain what are you referring to "other parts of API" . If you are asking for other integrations are working, then yes jfrog artifactory plugin and jira plugin are working fine. Facing issue with sonarqube only.

Also, as I mentioned earlier in postman if I hit sonarqube api "api/components/search" , it works fine with project token, but if I hit same api with backstage host, it return backstage login page html

Are you using a proxy or the sonarqube backend. I tried with both but none of them worked.

you may need to set the following setting to the internal url of the backend api. What do you mean by that. I did add this in app-config. Is this the same you are talking about else please guide me.

@vinzscam
Copy link
Member

@vinzscam

The annotation I am using is: sonarqube.org/project-key: "" as suggested in the document.

Can you please tell me with example what exactly should come in tenantA or projectA or what is instanceA in instanceA/projectA -> projectInstance = "instanceA" & projectKey = "projectA". I have defined instanceA in app-config as given below but it not work for me:

sonarqube: instances: - name: default baseUrl: apiKey: squ_......

I have no idea, I'm not familiar with the plugin. But looking at the documentation it suggests the following:
https://github.com/backstage/community-plugins/tree/main/workspaces/sonarqube/plugins/sonarqube-backend#example---single-global-instance

so the value of sonarqube.org/project-key is supposed to be defined by two parts (instance name, project key) separated by /

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants