forked from bitbar/cloud-api-client-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.sonar
53 lines (45 loc) · 1.51 KB
/
Jenkinsfile.sonar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env groovy
@Library('CloudOrchestrationLibrary')
import com.bitbar.Config
node('npm && chromium && docker') {
ansiColor('xterm') {
stage('Checkout') {
git([
url : '[email protected]:bitbar/cloud-api-client-js.git',
branch : env.BRANCH_NAME,
credentialsId: Config.github.credentialsId,
poll : true
])
}
stage('Install') {
sh('npm ci')
}
stage('Build') {
sh('npm run build')
}
stage('Tests with coverage') {
timeout([
time: 5,
activity: true,
unit: 'MINUTES'
]) {
sh('npm run test:coverage')
}
}
stage('Sonar') {
sh('echo $(jq -r .version package.json) > VERSION')
withCredentials([string(credentialsId: 'SONAR_TOKEN', variable: 'SONAR_TOKEN')]) {
sh("""
docker run -i --rm --name sonarqube-scanner-cloud-api-client-js-${env.BUILD_ID} \
-e SONAR_HOST_URL='https://sonarqube.smartbear.io' \
-e SONAR_LOGIN=$SONAR_TOKEN \
-v \"\$(pwd)\":/usr/src \
sonarsource/sonar-scanner-cli \
-Dsonar.projectVersion=`cat VERSION` \
-Dsonar.branch.name=${env.BRANCH_NAME} \
-Dsonar.javascript.lcov.reportPaths=\"coverage/lcov.info\"
""")
}
}
}
}