Skip to content

Commit aeb58f8

Browse files
jduquettegpacix
authored andcommitted
Sonar (#125)
* Added properties file for sonar scans * Updates to support Sonar * More sonar * More Sonar configuration * More Sonar configuration * More Sonar configuration * sonar config * Cleaning workspace * leaving workspace * Maybe no NPM is needed here * Maybe no NPM is needed here * Maybe no NPM is needed here * Maybe NPM is needed here * Fixing Sonar * Define the sonar host * Using build in sonar * Running from base * Running from base * More Sonar * Run sonar with a container that has java * Running in individual containers * Re-enabled slack notifications * Removed extra } * Formatting * SlackSend
1 parent 0c28340 commit aeb58f8

File tree

6 files changed

+1114
-37
lines changed

6 files changed

+1114
-37
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,7 @@ testem.log
4141
# System Files
4242
.DS_Store
4343
Thumbs.db
44+
45+
# Sonar
46+
/.scannerwork
47+
/.scannerwork/*

Jenkinsfile

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,55 @@ void setBuildStatus(String message, String state) {
99
}
1010

1111
pipeline {
12-
agent {
13-
docker {
14-
image 'duluca/minimal-node-chromium'
15-
}
12+
agent {
13+
label 'excellanator'
1614
}
17-
environment {
15+
environment {
1816
HOME = '.'
19-
}
20-
stages {
21-
stage('Checkout') {
22-
steps {
23-
slackSend(channel: '#tcp-angular', color: '#FFFF00', message: ":jenkins-triggered: Build Started - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)")
24-
checkout scm
25-
}
2617
}
27-
stage('Install') {
28-
steps {
29-
sh 'npm install'
18+
stages {
19+
stage('Checkout') {
20+
agent { docker 'duluca/minimal-node-chromium' }
21+
steps {
22+
slackSend(channel: '#tcp-angular', color: '#FFFF00', message: ":jenkins-triggered: Build Triggered - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)")
23+
checkout scm
24+
}
3025
}
31-
}
32-
stage('Build') {
33-
steps {
34-
sh 'npm run build'
26+
stage('Install') {
27+
agent { docker 'duluca/minimal-node-chromium' }
28+
steps {
29+
sh 'npm install'
30+
}
3531
}
36-
}
37-
stage('Test') {
38-
steps {
39-
sh 'npm run test:headless -- --watch false'
32+
stage('Build') {
33+
agent { docker 'duluca/minimal-node-chromium' }
34+
steps {
35+
sh 'npm run build'
36+
}
37+
}
38+
stage('Test') {
39+
agent { docker 'duluca/minimal-node-chromium' }
40+
steps {
41+
sh 'npm run test:headless -- --watch false --code-coverage'
42+
}
43+
}
44+
stage('SonarQube analysis') {
45+
agent { docker 'daneweber/ubuntu-node-java' }
46+
steps{
47+
withSonarQubeEnv('default') {
48+
sh 'npm run sonar'
49+
}
50+
}
4051
}
4152
}
42-
}
43-
post {
44-
success {
45-
setBuildStatus("Build succeeded", "SUCCESS");
46-
slackSend(channel: '#tcp-angular', color: '#00FF00', message: ":jenkins_ci: Build Successful! ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>) :jenkins_ci:")
47-
}
48-
failure {
49-
setBuildStatus("Build failed", "FAILURE");
50-
slackSend(channel: '#tcp-angular', color: '#FF0000', message: ":alert: :jenkins_exploding: *Build Failed! WHO BROKE THE FREAKING CODE??* ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>) :jenkins_exploding: :alert:")
53+
post {
54+
success {
55+
setBuildStatus("Build succeeded", "SUCCESS");
56+
slackSend(channel: '#tcp-angular', color: '#00FF00', message: ":jenkins_ci: Build Successful! ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>) :jenkins_ci:")
57+
}
58+
failure {
59+
setBuildStatus("Build failed", "FAILURE");
60+
slackSend(channel: '#tcp-angular', color: '#FF0000', message: ":alert: :jenkins_exploding: *Build Failed! WHO BROKE THE FREAKING CODE??* ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>) :jenkins_exploding: :alert:")
61+
}
5162
}
52-
}
5363
}

karma.conf.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,27 @@ module.exports = function (config) {
1212
require('karma-coverage-istanbul-reporter'),
1313
require('@angular-devkit/build-angular/plugins/karma'),
1414
require('karma-spec-reporter'),
15+
require('karma-sonarqube-reporter'),
1516
],
1617
client: {
1718
clearContext: false // leave Jasmine Spec Runner output visible in browser
1819
},
1920
coverageIstanbulReporter: {
2021
dir: require('path').join(__dirname, './coverage/tcp-angular'),
21-
reports: ['html', 'lcovonly', 'text-summary'],
22+
reports: ['html', 'lcovonly', 'text-summary' ],
2223
fixWebpackSourcePaths: true
2324
},
24-
reporters: ['progress', 'kjhtml', 'spec'],
25+
sonarqubeReporter: {
26+
basePath: 'src/app',
27+
filePattern: '**/*spec.ts',
28+
encoding: 'utf-8',
29+
outputFolder: 'reports',
30+
legacyMode: false,
31+
reportName: (metadata) => {
32+
return 'utExecution.xml'
33+
}
34+
},
35+
reporters: ['progress', 'kjhtml', 'spec', 'sonarqube' ],
2536
port: 9876,
2637
colors: true,
2738
logLevel: config.LOG_INFO,

0 commit comments

Comments
 (0)