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

🐛 Sonarqube: No information to display, however, the settings are correct #1350

Open
2 tasks done
padupe opened this issue Sep 26, 2024 · 2 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@padupe
Copy link

padupe commented Sep 26, 2024

Plugin Name

sonarqube

📜 Description

The settings are in accordance with the Backend and Frontend plugin documentation.

However, I receive the message on the frontend:
No information to display

👍 Expected behavior

Sonarqube information is expected to be rendered as expected.

👎 Actual Behavior with Screenshots

Captura de Tela 2024-09-26 às 10 07 10 Captura de Tela 2024-09-26 às 09 53 19

👟 Reproduction steps

  1. Config at app-config.yaml:
sonarqube:
  baseUrl: https://sonarcloud.acme.com
  apiKey: ${SONARQUBE_TOKEN}
  1. Config at catalog-info.yaml:
apiVersion: backstage.io/v1alpha1
kind: Component
metadata:
  name: gac-front-end
  description: Frontend GAC
  annotations:
    sonarqube.org/project-key: AP02126_GAC_FRONT_END
    github.com/project-slug: acme/gac-front-end
spec:
  type: service
  owner: group:squad-gac
  lifecycle: production
  1. Backend config
// packages/backend/src/index.ts
import { createBackend } from '@backstage/backend-defaults'

[...]

// New Backend System
const backend = createBackend()

[...] // Other plugins

backend.add(import('@backstage-community/plugin-sonarqube-backend'))

backend.start()
  1. EntityPage.tsx
// packages/app/src/components/EntityPage
import React from 'react';
import { EntitySonarQubeCard } from '@backstage-community/plugin-sonarqube';

[...]

const overviewCard = (
    <Grid container spacing={3} alignItems="stretch">
        {entityWarningContent}
        <Grid item md={6}>
           <EntityAboutCard variant="gridItem" />
        </Grid>
        <Grid item md={6}>
            <EntitySonarQubeCard variant="gridItem" />
        </Grid>

    [...]

     </Grid>
)

📃 Provide the context for the Bug.

I suspect it may be something related to CORS, but before the plugin was "migrated" to "community-plugins" it worked perfectly in a local environment.

👀 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?

No, but I'm happy to collaborate on a PR with someone else

@padupe padupe added the bug Something isn't working label Sep 26, 2024
@LegendSebastianoL
Copy link

LegendSebastianoL commented Oct 4, 2024

interesting, we are using the same plugin and it's working as expected 🤔

sonarqube:
  baseUrl: ${SONARQUBE_BASE_URL}
  apiKey: ${SONARQUBE_API_KEY}

backend:
  baseUrl: ${BACKEND_BASE_URL}
  listen:
    port: 7007

  csp:
    connect-src:
      [
        "'self'",
        "'unsafe-eval'",
        "'unsafe-inline'",
        'https://api.github.com/repos/',
        'https://pipelines.actions.githubusercontent.com/',
        'https://api.pagerduty.com/',
      ]
    default-src: ['https://www.loom.com/', '*']
    script-src: ["'self'", "'unsafe-inline'", "'unsafe-eval'"]
    img-src: ["'self'", '*', 'data:']
  cors:
    origin: ${APP_BASE_URL}
    methods: [GET, HEAD, PATCH, POST, PUT, DELETE]
    credentials: true
"@backstage-community/plugin-sonarqube": "^0.8.2",

---

export const hasSonarqube = (entity: Entity) =>
  entityHasAnnotation(entity, 'sonarqube.org/project-key');

---

// Routes.tsx

  <>
    <EntityLayout.Route path="/sonarqube" title="Sonarqube" if={hasSonarqube}>
      <Grid container spacing={3} alignItems="stretch">
        <Grid md={12}>
          <EntitySonarQubeCard variant="gridItem" />
        </Grid>
      </Grid>
    </EntityLayout.Route>
  </>

index.ts in the BE

"@backstage-community/plugin-sonarqube-backend": "^0.2.23",

---

backend.add(import('@backstage-community/plugin-sonarqube-backend'));

@vinzscam
Copy link
Member

vinzscam commented Oct 8, 2024

according to the code the sonarqube.org/project-key annotation should be in one of the following format:

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

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