Skip to content

Commit 784df9d

Browse files
authoredMay 8, 2018
fix(1007): Add getLinks method (screwdriver-cd#2)
* fix(1007): Add getLinks method * fix: Update README
1 parent 54368d8 commit 784df9d

File tree

6 files changed

+38
-11
lines changed

6 files changed

+38
-11
lines changed
 

‎CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Contributing to Screwdriver
22

3-
Have a look at our guidelines, as well as pointers on where to start making changes, in our official [documentation](http://docs.screwdriver.cd/about/contributing).
3+
Have a look at our guidelines, as well as pointers on where to start making changes, in our official [documentation](https://docs.screwdriver.cd/about/contributing/pull-requests).

‎LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2017 Yahoo Inc.
1+
Copyright 2018 Yahoo Inc.
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without

‎README.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
## Usage
77

88
```bash
9-
npm install screwdriver-screwdriver-coverage-sonar
9+
npm install screwdriver-coverage-sonar
1010
```
1111

1212
## Testing
@@ -15,17 +15,20 @@ npm install screwdriver-screwdriver-coverage-sonar
1515
npm test
1616
```
1717

18+
## Related Links
19+
- See [coverage-base](https://github.com/screwdriver-cd/coverage-base)
20+
1821
## License
1922

2023
Code licensed under the BSD 3-Clause license. See LICENSE file for terms.
2124

22-
[npm-image]: https://img.shields.io/npm/v/screwdriver-screwdriver-coverage-sonar.svg
23-
[npm-url]: https://npmjs.org/package/screwdriver-screwdriver-coverage-sonar
24-
[downloads-image]: https://img.shields.io/npm/dt/screwdriver-screwdriver-coverage-sonar.svg
25-
[license-image]: https://img.shields.io/npm/l/screwdriver-screwdriver-coverage-sonar.svg
25+
[npm-image]: https://img.shields.io/npm/v/screwdriver-coverage-sonar.svg
26+
[npm-url]: https://npmjs.org/package/screwdriver-coverage-sonar
27+
[downloads-image]: https://img.shields.io/npm/dt/screwdriver-coverage-sonar.svg
28+
[license-image]: https://img.shields.io/npm/l/screwdriver-coverage-sonar.svg
2629
[issues-image]: https://img.shields.io/github/issues/screwdriver-cd/screwdriver-coverage-sonar.svg
2730
[issues-url]: https://github.com/screwdriver-cd/screwdriver-coverage-sonar/issues
28-
[status-image]: https://cd.screwdriver.cd/pipelines/pipelineid/badge
29-
[status-url]: https://cd.screwdriver.cd/pipelines/pipelineid
31+
[status-image]: https://cd.screwdriver.cd/pipelines/706/badge
32+
[status-url]: https://cd.screwdriver.cd/pipelines/706
3033
[daviddm-image]: https://david-dm.org/screwdriver-cd/screwdriver-coverage-sonar.svg?theme=shields.io
3134
[daviddm-url]: https://david-dm.org/screwdriver-cd/screwdriver-coverage-sonar

‎index.js

+13
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,19 @@ class CoverageSonar extends CoverageBase {
154154
.then(res => res.token);
155155
}
156156

157+
/**
158+
* Return links to the Sonar badge and project
159+
* @method getLinks
160+
* @param {Object} jobId Project ID
161+
* @return {Promise} An object with coverage badge link and project link
162+
*/
163+
_getLinks(jobId) {
164+
return Promise.resolve({
165+
badge: `${this.config.sonarHost}/api/badges/measure?key=job%3A${jobId}&metric=coverage`,
166+
project: `${this.config.sonarHost}/dashboard?id=job%3A${jobId}`
167+
});
168+
}
169+
157170
/**
158171
* Get shell command to upload coverage to server
159172
* @method _getUploadCoverageCmd

‎package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "screwdriver-coverage-sonar",
3-
"version": "0.0.1",
3+
"version": "1.0.0",
44
"description": "SonarQube implementation of the coverage-base class",
55
"main": "index.js",
66
"scripts": {
@@ -41,7 +41,7 @@
4141
"joi": "^13.2.0",
4242
"request": "^2.85.0",
4343
"request-promise-native": "^1.0.5",
44-
"screwdriver-coverage-base": "^1.0.1",
44+
"screwdriver-coverage-base": "^1.0.3",
4545
"uuid": "^3.2.1"
4646
},
4747
"release": {

‎test/index.test.js

+11
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ describe('index test', () => {
6464
});
6565
});
6666

67+
describe('getLinks', () => {
68+
it('returns links', () => {
69+
sonarPlugin.getLinks('1').then(result =>
70+
assert.deepEqual(result, {
71+
badge: `${config.sonarHost}/api/badges/measure?key=job%3A1&metric=coverage`,
72+
project: `${config.sonarHost}/dashboard?id=job%3A1`
73+
})
74+
);
75+
});
76+
});
77+
6778
describe('getAccessToken', () => {
6879
const buildCredentials = { jobId: 1 };
6980

0 commit comments

Comments
 (0)
Please sign in to comment.