This repository has been archived by the owner on Jul 5, 2019. It is now read-only.
/
Jenkinsfile
74 lines (67 loc) · 2.14 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
pipeline {
agent any
stages {
stage('Install') {
steps {
sh 'npm install'
}
}
stage('Make Quality') {
environment {
GITHUB_TOKEN = credentials('GITHUB_TOKEN_TWALL')
}
when {
expression { BRANCH_NAME ==~ /(master|PR-[0-9]*)/ }
}
steps {
sh 'npm run lint'
script {
def scannerHome = tool 'SonarQube Scanner'
def scannerOptions = ''
if(env.BRANCH_NAME ==~ /PR-[0-9]*/) {
scannerOptions = scannerOptions + " -Dsonar.analysis.mode=preview"
scannerOptions = scannerOptions + " -Dsonar.github.repository=GDG-Lille/twall"
scannerOptions = scannerOptions + " -Dsonar.github.oauth=${GITHUB_TOKEN}"
scannerOptions = scannerOptions + " -Dsonar.github.pullRequest=${env.CHANGE_ID}"
}
withSonarQubeEnv('SonarQube Server') {
sh "${scannerHome}/bin/sonar-scanner${scannerOptions}"
}
}
}
}
stage('Build') {
steps {
script {
def target = '--configuration=staging'
if(env.BRANCH_NAME == 'master') {
target = '--configuration=production'
}
sh "npm run build -- ${target}"
}
}
}
stage('Deploy') {
environment {
FIREBASE_TOKEN = credentials('FIREBASE_TOKEN_TWALL')
}
when {
expression { BRANCH_NAME ==~ /(master|PR-[0-9]*)/ }
}
steps {
script {
def project = '-P default'
if(env.BRANCH_NAME == 'master') {
project = '-P prod'
}
sh "npm run deploy -- ${project}"
}
}
}
}
post {
always {
deleteDir()
}
}
}