-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
99 lines (93 loc) · 2.54 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
pipeline {
agent {
label 'worker'
}
options {
timeout(time: 30, unit: 'MINUTES')
}
environment {
REPO_NAME = sh(returnStdout: true, script: 'basename `git remote get-url origin` .git').trim()
VERSION = sh(returnStdout: true, script: 'grep -Po "\\"version\\": \\"\\K([^\\"]+)" package.json').trim()
LATEST_AUTHOR = sh(returnStdout: true, script: 'git show -s --pretty=%an').trim()
LATEST_COMMIT_ID = sh(returnStdout: true, script: 'git describe --tags --long --always').trim()
PATH = "${WORKSPACE}/node_modules/.bin:${env.PATH}"
}
stages {
stage ('Install') {
steps {
script {
echo REPO_NAME
echo LATEST_AUTHOR
echo LATEST_COMMIT_ID
echo env.BRANCH_NAME
echo env.BUILD_NUMBER
echo env.TAG_NAME
}
nodejs('NodeJS 18') {
sh 'npm install'
}
}
post {
failure {
basicsend("*${REPO_NAME}*-build nr. ${env.BUILD_NUMBER} *failed* to install packages, check your packages.json file (<${env.BUILD_URL}|Open Build in Jenkins>). Latest commit from ${LATEST_AUTHOR}.")
}
}
}
stage ('Build') {
steps {
nodejs('NodeJS 18') {
sh 'npm run build:prod'
}
}
post {
failure {
rocket_buildfail()
}
}
}
stage ('Test') {
steps {
nodejs('NodeJS 18') {
sh 'ng test --karma-config karma-jenkins.conf.js --code-coverage'
}
}
post {
failure {
rocket_testfail()
}
}
}
stage ('Reports and Statistics') {
steps {
script {
def scannerHome = tool 'SonarScanner 4';
withSonarQubeEnv('sonarcloud GIScience/ohsome') {
SONAR_CLI_PARAMETER = "-Dsonar.projectVersion=${VERSION} "
if (env.CHANGE_ID) {
SONAR_CLI_PARAMETER +=
"-Dsonar.pullrequest.key=${env.CHANGE_ID} " +
"-Dsonar.pullrequest.branch=${env.CHANGE_BRANCH} " +
"-Dsonar.pullrequest.base=${env.CHANGE_TARGET}"
} else {
SONAR_CLI_PARAMETER += "-Dsonar.branch.name=${env.BRANCH_NAME}"
}
nodejs('NodeJS 18') {
sh "${scannerHome}/bin/sonar-scanner " + SONAR_CLI_PARAMETER
}
}
}
}
post {
failure {
rocket_reportfail()
}
}
}
stage('Wrapping Up') {
steps {
encourage()
status_change()
}
}
}
}