Skip to main content

Check out Port for yourself ➜ 

Examples

To view and test the integration's mapping against examples of the third-party API responses, use the jq playground in your data sources page. Find the integration in the list of data sources and click on it to open the playground.

Project

Projects blueprint (Click to expand)
{
"identifier": "sonarQubeProject",
"title": "SonarQube Project",
"icon": "sonarqube",
"schema": {
"properties": {
"organization": {
"type": "string",
"title": "Organization",
"icon": "TwoUsers"
},
"link": {
"type": "string",
"format": "url",
"title": "Link",
"icon": "Link"
},
"lastAnalysisDate": {
"type": "string",
"format": "date-time",
"icon": "Clock",
"title": "Last Analysis Date"
},
"qualityGateStatus": {
"title": "Quality Gate Status",
"type": "string",
"enum": [
"OK",
"WARN",
"ERROR"
],
"enumColors": {
"OK": "green",
"WARN": "yellow",
"ERROR": "red"
}
},
"numberOfBugs": {
"type": "number",
"title": "Number Of Bugs"
},
"numberOfCodeSmells": {
"type": "number",
"title": "Number Of CodeSmells"
},
"numberOfVulnerabilities": {
"type": "number",
"title": "Number Of Vulnerabilities"
},
"numberOfHotSpots": {
"type": "number",
"title": "Number Of HotSpots"
},
"numberOfDuplications": {
"type": "number",
"title": "Number Of Duplications"
},
"coverage": {
"type": "number",
"title": "Coverage"
},
"mainBranch": {
"type": "string",
"icon": "Git",
"title": "Main Branch"
},
"mainBranchLastAnalysisDate": {
"type": "string",
"format": "date-time",
"icon": "Clock",
"title": "Main Branch Last Analysis Date"
},
"revision": {
"type": "string",
"title": "Revision"
},
"managed": {
"type": "boolean",
"title": "Managed"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"aggregationProperties": {
"criticalOpenIssues": {
"title": "Number Of Open Critical Issues",
"type": "number",
"target": "sonarQubeIssue",
"query": {
"combinator": "and",
"rules": [
{
"property": "status",
"operator": "in",
"value": ["OPEN", "REOPENED"]
},
{
"property": "severity",
"operator": "=",
"value": "CRITICAL"
}
]
},
"calculationSpec": {
"calculationBy": "entities",
"func": "count"
}
},
"numberOfOpenIssues": {
"title": "Number Of Open Issues",
"type": "number",
"target": "sonarQubeIssue",
"query": {
"combinator": "and",
"rules": [
{
"property": "status",
"operator": "in",
"value": [
"OPEN",
"REOPENED"
]
}
]
},
"calculationSpec": {
"calculationBy": "entities",
"func": "count"
}
}
},
"relations": {}
}
Integration configuration (Click to expand)
Define your own metrics

Besides filtering the API data, the integration provides a mechanism to allow users to define their own list of metrics used in SonarQube to evaluate the code. This list can be defined in the selector.metrics property. A complete list of valid SonarQube metrics can be in the SonarQube documentation.

createMissingRelatedEntities: true
deleteDependentEntities: true
resources:
- kind: projects_ga
selector:
query: 'true'
apiFilters:
qualifier:
- TRK
metrics:
- code_smells
- coverage
- bugs
- vulnerabilities
- duplicated_files
- security_hotspots
- new_violations
- new_coverage
- new_duplicated_lines_density
port:
entity:
mappings:
blueprint: '"sonarQubeProject"'
identifier: .key
title: .name
properties:
organization: .organization
link: .__link
qualityGateStatus: .__branch.status.qualityGateStatus
lastAnalysisDate: (.lastAnalysisDate // null) | if . then sub("(?<h>[+-]\\d{2})(?<m>\\d{2})$"; "\(.h):\(.m)") else null end
numberOfBugs: .__measures[]? | select(.metric == "bugs") | .value
numberOfCodeSmells: .__measures[]? | select(.metric == "code_smells") | .value
numberOfVulnerabilities: .__measures[]? | select(.metric == "vulnerabilities") | .value
numberOfHotSpots: .__measures[]? | select(.metric == "security_hotspots") | .value
numberOfDuplications: .__measures[]? | select(.metric == "duplicated_files") | .value
coverage: .__measures[]? | select(.metric == "coverage") | .value
mainBranch: .__branch.name
mainBranchLastAnalysisDate: (.__branch.analysisDate // null) | if . then sub("(?<h>[+-]\\d{2})(?<m>\\d{2})$"; "\(.h):\(.m)") else null end
revision: .revision
managed: .managed

Issue

Issue blueprint (Click to expand)
{
"identifier": "sonarQubeIssue",
"title": "SonarQube Issue",
"icon": "sonarqube",
"schema": {
"properties": {
"type": {
"type": "string",
"title": "Type",
"enum": ["CODE_SMELL", "BUG", "VULNERABILITY"]
},
"severity": {
"type": "string",
"title": "Severity",
"enum": ["MAJOR", "INFO", "MINOR", "CRITICAL", "BLOCKER"],
"enumColors": {
"MAJOR": "orange",
"INFO": "green",
"CRITICAL": "red",
"BLOCKER": "red",
"MINOR": "yellow"
}
},
"link": {
"type": "string",
"format": "url",
"icon": "Link",
"title": "Link"
},
"status": {
"type": "string",
"title": "Status",
"enum": ["OPEN", "CLOSED", "RESOLVED", "REOPENED", "CONFIRMED"]
},
"assignees": {
"title": "Assignees",
"type": "string",
"icon": "TwoUsers"
},
"tags": {
"type": "array",
"title": "Tags"
},
"createdAt": {
"type": "string",
"format": "date-time",
"title": "Created At"
}
}
},
"mirrorProperties": {},
"calculationProperties": {},
"relations": {
"sonarQubeProject": {
"target": "sonarQubeProject",
"required": false,
"title": "SonarQube Project",
"many": false
}
}
}
Integration configuration (Click to expand)
filter issues

The integration provides an option to filter the data that is retrieved from the SonarQube API using the following attributes:

  1. assigned: To retrieve assigned or unassigned issues. Accepts values: yes, no, true, false
  2. assignees: A list of assignee logins
  3. cleanCodeAttributeCategories: List of clean code attribute categories. Accepts values: ADAPTABLE, CONSISTENT, INTENTIONAL, RESPONSIBLE
  4. createdBefore: To retrieve issues created before the given date
  5. createdAfter: To retrieve issues created after the given date
  6. impactSeverities: List of impact severities. Accepts values: HIGH, LOW, MEDIUM
  7. impactSoftwareQualities: List of impact software qualities. Accepts values: MAINTAINABILITY, RELIABILITY, SECURITY
  8. statuses: List of statuses. Accepts values: OPEN, CONFIRMED, FALSE_POSITIVE, ACCEPTED, FIXED
  9. languages: List of languages
  10. resolved: To retrieve resolved or unresolved issues. Accepts values: yes, no, true, false
  11. scopes: List of scopes. Accepts values: MAIN, TESTS
  12. tags: List of tags

These attributes can be enabled using the path: selector.apiFilters. By default, the integration fetches unresolved SonarQube issues. It is also possible to configure the integration to fetch issues from a SonarQube project using the path: selector.projectApiFilters.filter while specifying any of project attributes listed above.

createMissingRelatedEntities: true
deleteDependentEntities: true
resources:
- kind: issues
selector:
query: "true"
apiFilters:
resolved: 'false'
projectApiFilters:
filter:
qualifier: TRK
port:
entity:
mappings:
blueprint: '"sonarQubeIssue"'
identifier: .key
title: .message
properties:
type: .type
severity: .severity
link: .__link
status: .status
assignees: .assignee
tags: .tags
createdAt: .creationDate
relations:
sonarQubeProject: .project

Saas Analysis

Saas analysis blueprint (Click to expand)
{
"identifier": "sonarQubeAnalysis",
"title": "SonarQube Analysis",
"icon": "sonarqube",
"schema": {
"properties": {
"branch": {
"type": "string",
"title": "Branch",
"icon": "GitVersion"
},
"fixedIssues": {
"type": "number",
"title": "Fixed Issues"
},
"newIssues": {
"type": "number",
"title": "New Issues"
},
"coverage": {
"title": "Coverage",
"type": "number"
},
"duplications": {
"type": "number",
"title": "Duplications"
},
"createdAt": {
"type": "string",
"format": "date-time",
"title": "Created At"
}
}
},
"mirrorProperties": {},
"calculationProperties": {},
"relations": {
"sonarQubeProject": {
"target": "sonarQubeProject",
"required": false,
"title": "SonarQube Project",
"many": false
}
}
}
Integration configuration (Click to expand)
createMissingRelatedEntities: true
deleteDependentEntities: true
resources:
- kind: saas_analysis
selector:
query: "true"
port:
entity:
mappings:
blueprint: '"sonarQubeAnalysis"'
identifier: .analysisId
title: .__commit.message // .analysisId
properties:
branch: .__branchName
fixedIssues: .measures.violations_fixed
newIssues: .measures.violations_added
coverage: .measures.coverage_change
duplications: .measures.duplicated_lines_density_change
createdAt: .__analysisDate
relations:
sonarQubeProject: .__project

On-Premise Analysis

On-premise analysis blueprint (Click to expand)
{
"identifier": "sonarQubeAnalysis",
"title": "SonarQube Analysis",
"icon": "sonarqube",
"schema": {
"properties": {
"branch": {
"type": "string",
"title": "Branch",
"icon": "GitVersion"
},
"fixedIssues": {
"type": "number",
"title": "Fixed Issues"
},
"newIssues": {
"type": "number",
"title": "New Issues"
},
"coverage": {
"title": "Coverage",
"type": "number"
},
"duplications": {
"type": "number",
"title": "Duplications"
},
"createdAt": {
"type": "string",
"format": "date-time",
"title": "Created At"
}
}
},
"mirrorProperties": {},
"calculationProperties": {},
"relations": {
"sonarQubeProject": {
"target": "sonarQubeProject",
"required": false,
"title": "SonarQube Project",
"many": false
}
}
}
Integration configuration (Click to expand)
createMissingRelatedEntities: true
deleteDependentEntities: true
resources:
- kind: onprem_analysis
selector:
query: 'true'
port:
entity:
mappings:
blueprint: '"sonarQubeAnalysis"'
identifier: .__project + "-" + .key
title: .title
properties:
branch: .branch
newIssues: .__measures[]? | select(.metric == "new_violations") | .period.value
coverage: .__measures[]? | select(.metric == "new_coverage") | .period.value
duplications: .__measures[]? | select(.metric == "new_duplicated_lines_density") | .period.value
createdAt: .analysisDate
relations:
sonarQubeProject: .__project

Portfolio

Portfolio blueprint (Click to expand)
{
"identifier": "sonarQubePortfolio",
"title": "SonarQube Portfolio",
"icon": "sonarqube",
"schema": {
"properties": {
"description": {
"type": "string",
"title": "Description"
},
"visibility": {
"type": "string",
"title": "Visibility",
"enum": [
"PUBLIC",
"PRIVATE"
],
"enumColors": {
"PUBLIC": "green",
"PRIVATE": "lightGray"
}
},
"selectionMode": {
"type": "string",
"title": "Selection Mode",
"enum": [
"AUTO",
"MANUAL",
"NONE"
],
"enumColors": {
"AUTO": "blue",
"MANUAL": "green",
"NONE": "lightGray"
}
},
"disabled": {
"type": "boolean",
"title": "Disabled"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"aggregationProperties": {},
"relations": {
"referencedBy": {
"title": "Referenced By",
"target": "sonarQubePortfolio",
"required": false,
"many": true
},
"subPortfolios": {
"title": "Sub Portfolios",
"target": "sonarQubePortfolio",
"required": false,
"many": true
}
}
}
Integration configuration (Click to expand)
deleteDependentEntities: true
createMissingRelatedEntities: true
resources:
- kind: portfolios
selector:
query: 'true'
port:
entity:
mappings:
identifier: .key
title: .name
blueprint: '"sonarQubePortfolio"'
properties:
description: .description
visibility: if .visibility then .visibility | ascii_upcase else null end
selectionMode: if .selectionMode then .selectionMode | ascii_upcase else null end
disabled: .disabled
relations:
subPortfolios: .subViews | map(select((.qualifier | IN("VW", "SVW"))) | .key)
referencedBy: .referencedBy | map(select((.qualifier | IN("VW", "SVW"))) | .key)