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

[Feature][SonarQube Connection] Add support for SonarCloud #4838

Open
2 of 3 tasks
alexvaccaro opened this issue Mar 31, 2023 · 40 comments
Open
2 of 3 tasks

[Feature][SonarQube Connection] Add support for SonarCloud #4838

alexvaccaro opened this issue Mar 31, 2023 · 40 comments
Labels
add-a-plugin This issue is to add a plugin type/feature-request This issue is a proposal for something new

Comments

@alexvaccaro
Copy link

Search before asking

  • I had searched in the issues and found no similar feature requirement.

Use case

Add support SonarCloud along with SonarCube

Hopefully this is not a big ask, SonarCloud is the cloud hosted version of SonarCube and most of the apis are the same.

I have tried setting up a connection but unfortunately the list of projects comes back empty, for what I can see that's becaus efor SonarCloud the organisation parameter is required, yet the SonarCube connection wizard does not capture this parameter.

Description

No response

Related issues

No response

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@alexvaccaro alexvaccaro added the type/feature-request This issue is a proposal for something new label Mar 31, 2023
@klesh
Copy link
Contributor

klesh commented Apr 3, 2023

Thanks for your suggestion, @Startrekzky @yumengwang03 @hezyin please take a look at this.

@Startrekzky Startrekzky added the add-a-plugin This issue is to add a plugin label Apr 10, 2023
@Startrekzky
Copy link
Contributor

Collecting votes

@alexvaccaro
Copy link
Author

I see the issue has been tagged with 'add-a-plugin', however this could be potentially handled with the existing SonarCube plugin and have an optional 'Organisation' parameter to inject in the URIs if supplied

@Startrekzky
Copy link
Contributor

Startrekzky commented May 15, 2023

I see the issue has been tagged with 'add-a-plugin', however this could be potentially handled with the existing SonarCube plugin and have an optional 'Organisation' parameter to inject in the URIs if supplied

I agree and have removed the label. This issue is the improvements of #2305

@Startrekzky Startrekzky removed the add-a-plugin This issue is to add a plugin label May 15, 2023
@BrookeKatalon
Copy link

We're definitely interested as well - would be easier if the existing plugin could be adapted, or as second one that's sonarcloud-specific.

@Startrekzky
Copy link
Contributor

Startrekzky commented May 22, 2023

@klesh It seems we've got 4 (3+1) votes now. I'll plan it in the next few versions.

@Startrekzky Startrekzky added this to the v0.19.0 milestone May 22, 2023
@klesh
Copy link
Contributor

klesh commented May 23, 2023

LGTM

@Ragavendira1
Copy link

Dear team, we are looking out sonarcloud integration. Therefore kindly provide us update when we will able to see sonarcloud data into devlake

@Startrekzky Startrekzky modified the milestones: v0.19.0, v0.20 Jun 25, 2023
@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity for 30 days. It will be closed in next 7 days if no further activity occurs.

@github-actions github-actions bot added the Stale label Jul 26, 2023
@github-actions
Copy link

github-actions bot commented Aug 3, 2023

This issue has been closed because it has not received response for too long time. You could reopen it if you encountered similar problems in the future.

@github-actions github-actions bot closed this as completed Aug 3, 2023
@abeizn abeizn removed the Stale label Aug 3, 2023
@abeizn abeizn reopened this Aug 3, 2023
@lhart-intelycare
Copy link

Another vote from me!

@Startrekzky Startrekzky removed this from the v0.20 milestone Aug 21, 2023
@Startrekzky Startrekzky added the add-a-plugin This issue is to add a plugin label Aug 21, 2023
@sztukamichal
Copy link

Devlake looks great. I also vote on this functionality.

@rhanton
Copy link

rhanton commented Sep 29, 2023

I'm looking at how much devlake could help our org, but SonarCloud integration would make it quite amazing for us! Upvote from me!

Copy link

This issue has been automatically marked as stale because it has been inactive for 60 days. It will be closed in next 7 days if no further activity occurs.

@github-actions github-actions bot added the Stale label Nov 29, 2023
@rhanton
Copy link

rhanton commented Nov 29, 2023

Ping! Is this still possible? Anyone with time to look at it? We might have time for someone on the team to investigate in 2024.

@github-actions github-actions bot removed the Stale label Nov 30, 2023
@apache apache deleted a comment from abeizn Dec 4, 2023
@leandrofrs
Copy link

+1

@jhonjimenezmatrix
Copy link

+1 we need it!

Copy link

This issue has been automatically marked as stale because it has been inactive for 60 days. It will be closed in next 7 days if no further activity occurs.

@github-actions github-actions bot added the Stale label Mar 25, 2024
@gdolfen
Copy link

gdolfen commented Mar 25, 2024

+1

@github-actions github-actions bot removed the Stale label Mar 26, 2024
@Startrekzky Startrekzky changed the title [Feature][SonarCube Connection] Add support for SonarCloud [Feature][SonarQube Connection] Add support for SonarCloud Mar 26, 2024
@Startrekzky
Copy link
Contributor

Any volunteers? We don't have the bandwidth to do this, and we don't have an account for SonarCloud either.

@UncleLeoTheDad
Copy link

I started to explore this as I am a SonarCloud user. If you have any shortcuts to get started, I'd appreciate it.

I see this is the current plugin: https://github.com/apache/incubator-devlake/tree/main/backend/plugins/sonarqube

And I followed the "Develop a plugin" link on the main page to start:
https://github.com/apache/incubator-devlake

But I ended up at a dead link. :(
https://github.com/apache/incubator-devlake/blob/main/backend/DevelopmentSetup

@tonyjw
Copy link
Contributor

tonyjw commented Apr 9, 2024

Hi @UncleLeoTheDad I believe the right link is this: https://github.com/apache/incubator-devlake/blob/main/backend/DevelopmentManual.md

@rhanton
Copy link

rhanton commented Apr 16, 2024

@Startrekzky I'll see if someone on our team can take a look. We "finally" got a devlake instance running for our teams, so should be easy-er to test whatever we put together.

@tc-jason-gregory
Copy link

+1

1 similar comment
@HumSeto
Copy link

HumSeto commented Apr 22, 2024

+1

@Startrekzky
Copy link
Contributor

Hi @UncleLeoTheDad . I am sorry. I just saw your comment. Could you join the Slack community so that we can work more closely if you're still looking at it? Thank you.
https://join.slack.com/t/devlake-io/shared_invite/zt-18uayb6ut-cHOjiYcBwERQ8VVPZ9cQQw

@UncleLeoTheDad
Copy link

Hi @Startrekzky : tried that link, but it looks like it expired:
image

@wanisfahmyDE
Copy link
Contributor

here you go https://join.slack.com/t/devlake-io/shared_invite/zt-20envwfbk-JUTZ4z9jSeRnrvNhBFLg9w

@lezgin-bakircioglu-qred
Copy link

Awesome to see some movement on this one, looking forward to the sonarcloud support :)

@lhart-intelycare
Copy link

I've started coding away on my end. Wanted to get some advice on which way to go...

The big difference ID'd so far between sonarcloud and sonarqube is that:

  1. Sonarcloud always has the same REST endpoint: https://sonarcloud.io/api/
  2. Sonarcloud APIs often needs an "organization" passed in when looking for things like projects: https://sonarcloud.io/api/projects/search?deprecated=false&organization=intelycare&ps=100&p=1

Given that, it seemed like I should probably start with enhancing:

  1. config-ui's sonarqube pluginconfig to have a multiconfig concept, similar to the jira plugin and then add an optional concept of "organization" when multiconfig is selected: https://github.com/apache/incubator-devlake/blob/0e7bf408afcb707a419c843a4a9839b054b1c7d4/config-ui/src/plugins/register/sonarqube/config.tsx:
export const SonarQubeConfig: IPluginConfig = {
  plugin: 'sonarqube',
  name: 'SonarQube',
  icon: ({ color }) => <Icon fill={color} />,
  sort: 11,
  connection: {
    docLink: DOC_URL.PLUGIN.SONARQUBE.BASIS,
    fields: [
      'name',
      {
        key: 'endpoint',
        subLabel: 'Provide the SonarQube instance API endpoint. E.g. http://<host>:<port>/api/',
        multipleVersions: {
          cloud: 'http://sonarcloud.io/',
          server: ' '
        },
        organizationRequired: true,
      },
      'organization',
      'token',
      'proxy',
      {
        key: 'rateLimitPerHour',
        subLabel:
          'By default, DevLake uses 10,000 requests/hour for data collection for SonarQube. But you can adjust the collection speed by setting up your desirable rate limit.',
        learnMore: DOC_URL.PLUGIN.SONARQUBE.RATE_LIMIT,
        externalInfo: 'SonarQube does not specify a maximum value of rate limit.',
        defaultValue: 10000,
      },
    ],
  },
  dataScope: {
    title: 'Repositories',
  },
};
  1. The endpoint connection config component, allowing a user to select cloud vs server and then if cloud, specify an organization : https://github.com/apache/incubator-devlake/blob/f27c31f3954bb4d5df8c6a4e829acfdedf36174a/config-ui/src/plugins/components/connection-form/fields/endpoint.tsx
import { useState, useEffect } from 'react';
import type { RadioChangeEvent } from 'antd';
import { Radio, Input } from 'antd';

import { Block } from '@/components';

type VersionType = 'cloud' | 'server';

interface Props {
  subLabel?: string;
  disabled?: boolean;
  name: string;
  multipleVersions?: Record<VersionType, string>;
  organizationRequired?: boolean;
  initialValue: string;
  value: string;
  error: string;
  setValue: (value: string) => void;
  setError: (error: string) => void;
}

export const ConnectionEndpoint = ({
  subLabel,
  disabled = false,
  name,
  multipleVersions,
  organizationRequired,
  initialValue,
  value,
  setValue,
  setError,
}: Props) => {
  const [version, setVersion] = useState<VersionType>('cloud');

  useEffect(() => {
    setValue(initialValue);
    setVersion(initialValue === multipleVersions?.cloud ? 'cloud' : 'server');
  }, [initialValue]);

  useEffect(() => {
    setError(value ? '' : 'endpoint is required');
  }, [value]);

  const handleChange = (e: RadioChangeEvent) => {
    const version = e.target.value;
    if (version === 'cloud') {
      setValue(multipleVersions?.cloud ?? '');
    }

    if (version === 'server') {
      setValue('');
    }

    setVersion(version);
  };

  const handleChangeValue = (e: React.ChangeEvent<HTMLInputElement>) => {
    setValue(e.target.value);
  };

  if (multipleVersions) {
    return (
      <>
        <Block title={name} required>
          <Radio.Group value={version} onChange={handleChange}>
            <Radio value="cloud">{name} Cloud</Radio>
            <Radio value="server" disabled={!multipleVersions.server}>
              {name} Server {multipleVersions.server ? multipleVersions.server : '(to be supported)'}
            </Radio>
          </Radio.Group>
        </Block>
        {version === 'cloud' && (
          <Block>
            <p>
              If you are using {name} Cloud, you do not need to enter the endpoint URL, which is{' '}
              {multipleVersions.cloud}.
            </p>
          </Block>
        )}
        {organizationRequired && (
          <Block>
            <p>
              Place some input here for "organization"
            </p>
          </Block>
        )}
        {version === 'server' && (
          <Block
            title="Endpoint URL"
            description={subLabel ?? `If you are using ${name} Server, please enter the endpoint URL.`}
            required
          >
            <Input style={{ width: 386 }} placeholder="Your Endpoint URL" value={value} onChange={handleChangeValue} />
          </Block>
        )}
      </>
    );
  }

  return (
    <Block title="Endpoint URL" description={subLabel ?? `Provide the ${name} instance API endpoint.`} required>
      <Input
        style={{ width: 386 }}
        disabled={disabled}
        placeholder="Your Endpoint URL"
        value={value}
        onChange={handleChangeValue}
      />
    </Block>
  );
};

DevLake devs (@Startrekzky?): does this sound directionally correct from a front-end perspective? Alternatively, I could create an entirely new field concept here, but it feels like org is tightly coupled to endpoint vs being its own entity:
https://github.com/apache/incubator-devlake/blob/ac540080b73f313eb58b6a9659a392e1022beced/config-ui/src/plugins/components/connection-form/fields

Thanks!

@jcorremo
Copy link

Upvote from me

@mintsweet
Copy link
Member

Hi @lhart-intelycare,

In response to your inquiry about how config-ui handles the implementation of two different SonarQube modes:

Modifying existing fields, such as "endpoint," is not advisable as it may impact other plugins. If a new field is introduced in SonarQube Cloud, the best approach is to create a new component specifically for this field, similar to the authentication component used in Jira.

Within the new component, you can retrieve the value of the "endpoint" to ascertain whether the "organization" field is required.

Copy link

This issue has been automatically marked as stale because it has been inactive for 60 days. It will be closed in next 7 days if no further activity occurs.

@github-actions github-actions bot added the Stale label Aug 30, 2024
@mintsweet mintsweet removed the Stale label Aug 30, 2024
@lezgin-bakircioglu-qred

adding a comment to keep this one alive as there is some progress :)

@justinphelps
Copy link

Any luck? I saw that someone had PR that should enable Sonarcloud.

@lhart-intelycare
Copy link

That was me. I paused on that completed work, shared it with devinsight and they are actively working on enabling the feature (either using my code or starting from scratch) now. Should be coming soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add-a-plugin This issue is to add a plugin type/feature-request This issue is a proposal for something new
Projects
None yet
Development

Successfully merging a pull request may close this issue.