This repository has been archived by the owner on Sep 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Jenkinsfile
68 lines (62 loc) · 2.39 KB
/
Jenkinsfile
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env groovy
pipeline {
agent {label 'formbox'}
options { disableConcurrentBuilds() }
tools {nodejs 'node6.11.3'}
environment {
FIREFOX_BIN = "/opt/firefox/firefox"
}
stages {
stage('Build') {
steps {
sh 'npm install'
sh 'npm run build-jenkins'
}
}
stage('Quality Gate') {
steps {
sh 'npm run test-jenkins'
sh 'npm run webdriver-update -- --standalone false --chrome false'
sh '''#!/bin/bash
CHECK="init"
while [ -n "$CHECK" ]; do
PORT=$(shuf -i 50000-51000 -n 1)
CHECK=$(netstat -a)
if [[ $CHECK != *"$PORT"* ]]; then
CHECK=""
fi
done
npm run e2e -- --port $PORT
'''
}
post {
always {
junit '**/.results/*.xml'
script {
if (GIT_BRANCH == 'master') {
withSonarQubeEnv('SonarQube') {
sh 'npm run sonar'
}
timeout(time: 1, unit: 'HOURS') {
script {
def qg = waitForQualityGate()
if (qg.status != 'OK') {
error "Pipeline abgebrochen auf Grund von Quality Gate Fehlern: ${qg.status}"
}
}
}
} else {
withSonarQubeEnv('SonarQube') {
withCredentials([usernamePassword(credentialsId: '3eaee9fd-bbdd-4825-a4fd-6b011f9a84c3', passwordVariable: 'GITHUB_ACCESS_TOKEN', usernameVariable: 'USER')]) {
sh "npm run sonar -- -Dsonar.analysis.mode=preview -Dsonar.github.pullRequest=${env.CHANGE_ID} \
-Dsonar.github.repository=wollmux/formbox \
-Dsonar.github.oauth=${GITHUB_ACCESS_TOKEN}"
}
}
}
}
}
}
}
}
}