pn-sonarqube
v2.0.3
Published
integrates with build pipelines to analyse code with sonarqube
Downloads
85
Readme
Integrates with build pipelines to analyse code with sonarqube
Add script execution
invoke the bin from your build pipelines and supply what language (javascript or typescript, default is javascript) that is used in your project, the sonarqube url and the sonarqube token, the last two should be found from the global bitbucket variables $SONARQUBE_URL
and $SONARQUBE_PIPELINE_TOKEN
but can of course be supplied manually.
add lcov reporting
For this to work with your unit tests you must use lcov reporting.
an example of how this looks with nyc and mocha:
package.json
"scripts": {
"test": "./node_modules/.bin/nyc --reporter=lcov --reporter=text ./node_modules/.bin/mocha -r ts-node/register test/*.ts",
}
...
"nyc": {
"extension": [
".ts"
],
"require": [
"ts-node/register"
],
"include": [
"src/**/*"
],
"exclude": [
"**/*.d.ts"
],
"reporter": [
"text"
],
"all": true,
"check-coverage": false
}
Example bitbucket pipeline
bitbucket-pipelines.yml
# my-awesome-repo-thingys
image: node:12
pipelines:
branches:
master:
- step:
caches:
- node
script:
- npm install
- npm run lint
- npm test
- node --max-old-space-size=8192 ./node_modules/.bin/serverless deploy -s test -v
- ./node_modules/.bin/pn-sonarqube -lang ts -sonarurl $SONARQUBE_URL -token $SONARQUBE_PIPELINE_TOKEN -sources src
Options
| Parameter | Description | Required | Default | ------------- |:-------------: | -----: | -----:| | sonarurl | url for sonarqube | true | | | token | sonarqube token | true | | | sources | folder containing code to be analysed | false | root | | lang | ts or js, needed for test cases to be analysed | false | js |
Note
Pipeline must use node 8 or higher