| title | Monitor SonarQube projects in Catalog with the Konnect API | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| content_type | how_to | ||||||||||||||||||||
| description | Learn how to connect a SonarQube project to your {{site.konnect_catalog}} service in {{site.konnect_short_name}} using the API. | ||||||||||||||||||||
| products |
|
||||||||||||||||||||
| works_on |
|
||||||||||||||||||||
| tools |
|
||||||||||||||||||||
| tags |
|
||||||||||||||||||||
| search_aliases |
|
||||||||||||||||||||
| related_resources |
|
||||||||||||||||||||
| automated_tests | false | ||||||||||||||||||||
| tldr |
|
||||||||||||||||||||
| prereqs |
|
Before you can discover SonarQube projects in {{site.konnect_catalog}}, you must configure the SonarQube integration.
First, install the SonarQube integration:
{% konnect_api_request %} url: /v1/integration-instances method: POST status_code: 201 region: us body: integration_name: sonarqube name: sonarqube display_name: SonarQube config: {} {% endkonnect_api_request %}
Export the ID of your SonarQube integration:
export SONARQUBE_INTEGRATION_ID='YOUR-INTEGRATION-ID'Next, authorize the SonarQube integration with your SonarQube personal access token:
{% konnect_api_request %} url: /v1/integration-instances/$SONARQUBE_INTEGRATION_ID/auth-credential method: POST status_code: 201 region: us body: type: multi_key_auth config: headers: - name: authorization key: $SONARQUBE_PAT {% endkonnect_api_request %}
Once authorized, resources from your SonarQube account will be discoverable in the UI.
Create a service that you'll map to your SonarQube resources:
{% konnect_api_request %} url: /v1/catalog-services method: POST status_code: 201 region: us body: name: billing display_name: Billing Service {% endkonnect_api_request %}
Export the service ID:
export SONARQUBE_SERVICE_ID='YOUR-SERVICE-ID'Before you can map your SonarQube resources to a service in {{site.konnect_catalog}}, you first need to find the resources that are pulled in from SonarQube:
{% konnect_api_request %} url: /v1/resources?filter%5Bintegration.name%5D=sonarqube method: GET region: us status_code: 200 {% endkonnect_api_request %}
{:.info}
You might need to manually sync your SonarQube integration for resources to appear. From the {{site.konnect_short_name}} UI by navigating to the SonarQube integration you just installed and selecting Sync Now from the Actions dropdown menu.
Export the resource ID you want to map to the service:
export SONARQUBE_RESOURCE_ID='YOUR-RESOURCE-ID'Now, you can map the SonarQube resource to the service:
{% konnect_api_request %} url: /v1/resource-mappings method: POST status_code: 201 region: us body: service: billing resource: $SONARQUBE_RESOURCE_ID {% endkonnect_api_request %}
To confirm that the SonarQube resource is now mapped to the intended service, list the service’s mapped resources:
{% konnect_api_request %} url: /v1/catalog-services/$SONARQUBE_SERVICE_ID/resources method: GET status_code: 200 region: us {% endkonnect_api_request %}