-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJenkinsfile
More file actions
99 lines (96 loc) · 3.46 KB
/
Copy pathJenkinsfile
File metadata and controls
99 lines (96 loc) · 3.46 KB
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 'docker'
}
options {
buildDiscarder(logRotator(daysToKeepStr: '150', numToKeepStr: '30', artifactDaysToKeepStr: '30', artifactNumToKeepStr: '15'))
disableConcurrentBuilds()
timeout(time: 30, unit: 'MINUTES')
gitLabConnection('gitlab.isaac.nl')
gitlabBuilds(builds: [
'clean',
'checkout',
'update docker images',
'run unit tests'
])
}
stages {
stage('clean') {
steps {
gitlabCommitStatus(name: 'clean') {
// Cleanup entire workspace
deleteDir()
}
}
}
stage('checkout') {
steps {
gitlabCommitStatus(name: 'checkout') {
// Checkout the latest version
checkout scm
script {
env.DOCKER_TAG = env.BRANCH_NAME.toLowerCase().replaceAll(/[^a-z0-9_.\-]/, '-');
}
}
}
}
stage('update docker images') {
steps {
gitlabCommitStatus(name: 'update docker images') {
// Update the docker images in our docker registry.
script {
docker.withRegistry('https://rocked.isaac.local', 'docker-registry-app-ci') {
docker.build('rocked.isaac.local/payvision/payvision-sdk-javascript:' + env.DOCKER_TAG, '--pull .').push(env.DOCKER_TAG)
}
}
}
}
}
stage('run unit tests') {
steps {
gitlabCommitStatus(name: 'run unit tests') {
script {
docker.withRegistry('https://rocked.isaac.local', 'docker-registry-app-ci') {
docker.image('rocked.isaac.local/payvision/payvision-sdk-javascript:' + env.DOCKER_TAG).inside {
sh 'cd /app && npm run test tests/unit'
}
}
}
}
}
}
stage('sonarqube analysis') {
// We only run SonarQube analysis on our develop branch.
// The 'sonar-project.properties' that is bundled with this project is used for that purpose
when {
expression {
env.BRANCH_NAME == 'develop'
}
}
steps {
script {
scannerHome = tool 'sonar-runner 3.x'
}
withSonarQubeEnv('Sonar') {
sh "${scannerHome}/bin/sonar-scanner"
}
}
}
}
post {
failure {
// On failure, send an e-mail to the person who broke the build.
emailext (
subject: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """<p>FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
<p>Check console output at "<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>"</p>""",
recipientProviders: [
[$class: 'RequesterRecipientProvider'],
[$class: 'DevelopersRecipientProvider']
],
attachLog: true,
compressLog: true
)
}
}
}