screwdriver-coverage-sonar 4.1.2 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/commands.txt +1 -0
  2. package/index.js +14 -3
  3. package/package.json +3 -2
package/commands.txt CHANGED
@@ -1,3 +1,4 @@
1
+ if [ "$SD_PRIVATE_PIPELINE" = "true" ] && [ "$SD_ALLOW_PRIVATE_COVERAGE_SEND" != "true" ]; then echo "INFO - This is a private pipeline and sending coverage is not allowed." && exit 0; fi
1
2
  if [ ! -f sonar-project.properties ] && [ -z "$SD_SONAR_OPTS" ]; then echo "ERROR - No sonar project properties defined." && exit 0; fi
2
3
  if [ ! -z "$SD_PULL_REQUEST" ] && [ "$SD_SONAR_ENTERPRISE" = true ]; then export SD_SONAR_OPTS="${SD_SONAR_OPTS} -Dsonar.pullrequest.key=$SD_PULL_REQUEST -Dsonar.pullrequest.branch='${PR_BRANCH_NAME#*/}' -Dsonar.pullrequest.base='${PR_BASE_BRANCH_NAME}'"; fi
3
4
  if curl --version > /dev/null 2>&1; then SD_CURL_CMD_WRAPPER="eval"; else SD_CURL_CMD_WRAPPER="sd-step exec --pkg-version 7.54.1 core/curl"; fi
package/index.js CHANGED
@@ -296,13 +296,20 @@ class CoverageSonar extends CoverageBase {
296
296
  const [projectScope, id] = projectKey.split(':');
297
297
  const projectName = projectScope === 'pipeline' ? pipelineName : `${pipelineName}:${jobName}`;
298
298
  const username = `user-${projectScope}-${id}`;
299
-
300
- return {
299
+ const projectData = {
301
300
  projectKey,
302
301
  username,
303
302
  projectName,
304
303
  projectScope
305
304
  };
305
+
306
+ if (projectScope === 'pipeline') {
307
+ const componentId = encodeURIComponent(`pipeline:${id}`);
308
+
309
+ projectData.projectUrl = `${this.sonarHost}/dashboard?id=${componentId}`;
310
+ }
311
+
312
+ return projectData;
306
313
  }
307
314
 
308
315
  // Use user-configured scope; otherwise figure out default scope: pipeline scope for enterprise edition, job scope for everything else
@@ -310,11 +317,15 @@ class CoverageSonar extends CoverageBase {
310
317
  const coverageScope = userScope || (enterpriseEnabled ? 'pipeline' : 'job');
311
318
 
312
319
  if (coverageScope === 'pipeline') {
320
+ const componentId = encodeURIComponent(`pipeline:${pipelineId}`);
321
+ const projectUrl = `${this.sonarHost}/dashboard?id=${componentId}`;
322
+
313
323
  return {
314
324
  projectKey: `pipeline:${pipelineId}`,
315
325
  projectName: pipelineName,
316
326
  username: `user-pipeline-${pipelineId}`,
317
- projectScope: coverageScope
327
+ projectScope: coverageScope,
328
+ projectUrl
318
329
  };
319
330
  }
320
331
 
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "screwdriver-coverage-sonar",
3
- "version": "4.1.2",
3
+ "version": "4.3.0",
4
4
  "description": "SonarQube implementation of the coverage-base class",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "pretest": "eslint .",
8
- "test": "nyc --report-dir ./artifacts/coverage --reporter=lcov mocha --reporter mocha-multi-reporters --reporter-options configFile=./mocha.config.json --recursive --timeout 4000 --retries 1 --exit --allow-uncaught true --color true"
8
+ "test": "nyc --report-dir ./artifacts/coverage --reporter=lcov mocha --reporter mocha-multi-reporters --reporter-options configFile=./mocha.config.json --recursive --timeout 4000 --retries 1 --exit --allow-uncaught true --color true",
9
+ "test-debug": "mocha --inspect-brk ./test/**/*.js"
9
10
  },
10
11
  "repository": {
11
12
  "type": "git",