Contributed by Tiffany Kyi, Software Engineer, Verizon Media
Originally posted on screwdriver.cd
We have recently added SonarQube Enterprise Edition support to Screwdriver, which unlocks powerful Pull Request Workflows and improves build analysis performance. Cluster admins can follow instructions in the Cluster Admin Configuration section below to use SonarQube Enterprise.
In order to make use of these new Pull Request features and to better utilize our SonarQube license, we will be making the following changes:
- Sonar Project Key for your build will change from “job:<jobId>” to “pipeline:<pipelineId>”.
- If your project still needs multiple analysis at job level we will provide you with a job level annotation to get a Sonar Project Key scoped to a Job.
These changes will enable Screwdriver to provide a Pull Request Analysis feature for all builds.
Note: This will create a new Sonarqube project for your pipeline, however, your existing analysis data will not be migrated over to the new Sonarqube project.
User configuration
- If you are relying on the Screwdriver SonarQube integration to publish and view test coverage results in the Screwdriver build detail page, then no change is required.
- If you have a custom integration where you are manually constructing SonarQube scanner parameters, then you need to rely on
$SD_SONAR_PROJECT_KEY
&$SD_SONAR_PROJECT_NAME
for scanner parameters, which will be available in builds based on your project configuration. We have also added$SD_SONAR_ENTERPRISE
to indicate whether the cluster is using Enterprise (true) or open-source edition of SonarQube(false). - If you absolutely need to have a separate SonarQube analysis for each job, you need to add this annotation
screwdriver.cd/coverageScope: job
to your job configuration in your “screwdriver.yaml” file:
jobs:
main:
annotations:
screwdriver.cd/coverageScope: job
requires: [~pr, ~commit]
image: node:12
steps:
- install: npm install
- test: npm test
Cluster Admin configuration
In order to enable SonarQube Enterprise edition with Screwdriver, do the following steps:
- Get a SonarQube Enterprise license.
- Update the SonarQube Enterprise license in the SonarQube UI (https://SONAR_URL/admin/extension/license/app).
- Then, set
COVERAGE_SONAR_ENTERPRISE: true
in your config file.
Pull Request Decoration
To set up Pull Request Decoration in your GitHub PRs, follow these steps in the link below:
https://docs.sonarqube.org/latest/analysis/pr-decoration/
Note: Users will need to manually install the newly created GitHub app in their organizations and repos, and these will need to be manually configured in SonarQube projects.
You should see something like this:
Compatibility List
In order to have these improvements, you will need these minimum versions:
- API – v0.5.972
- Queue-Service – v1.0.22
- UI – v1.0.539
- Launcher – v6.0.87
- Build Cluster Worker – v1.18.8
Contributors
Thanks to the following contributors for making this feature possible:
Questions and Suggestions
We’d love to hear from you. If you have any questions, please feel free to reach out here. You can also visit us on GitHub and Slack.