forked from entrylabs/entryjs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
116 lines (116 loc) · 2.67 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
pipeline {
agent none
stages {
stage('EntryJS Test') {
when {
beforeAgent true
expression {
return env.CHANGE_ID
}
}
agent {
docker {
image 'node:8.11.3'
}
}
steps {
script {
sh "npm prune"
sh "npm install"
sh "yarn test"
}
}
post {
always {
junit 'reports/*.xml'
}
}
}
stage('SonarQube Analysis') {
when {
beforeAgent true
expression {
return env.CHANGE_ID
}
}
agent {
docker {
image 'maven:3-alpine'
}
}
steps {
script {
def scannerHome = tool "sonarqube-scanner";
withSonarQubeEnv("sonar") {
sh "${scannerHome}/bin/sonar-scanner " +
"-Dsonar.projectKey=entry.entryjs " +
"-Dsonar.projectName=entryjs " +
"-Dsonar.sourceEncoding=UTF-8 " +
"-Dsonar.analysis.mode=preview " +
"-Dsonar.github.repository=entrylabs/entryjs " +
"-Dsonar.github.endpoint=https://api.github.com " +
"-Dsonar.github.oauth=${GH_TOKEN} " +
"-Dsonar.issuesReport.console.enable=true " +
"-Dsonar.github.disableInlineComments=true " +
"-Dsonar.github.pullRequest=${env.CHANGE_ID} " +
"-Dsonar.sources=src "
}
}
}
}
stage('SonarQube Scan') {
when {
beforeAgent true
allOf {
expression { BRANCH_NAME ==~ /(^master$)/ }
not { changeRequest() }
}
}
agent {
docker {
image 'maven:3-alpine'
}
}
steps {
script {
def scannerHome = tool "sonarqube-scanner";
withSonarQubeEnv("sonar") {
sh "${scannerHome}/bin/sonar-scanner " +
"-Dsonar.projectKey=entry.entryjs " +
"-Dsonar.projectName=entryjs " +
"-Dsonar.sourceEncoding=UTF-8 " +
"-Dsonar.sources=src "
}
}
}
}
stage('EntryJS Deploy') {
when {
beforeAgent true
allOf {
expression { BRANCH_NAME ==~ /(^master$|^deploy\/.*$)/ }
not { changeRequest() }
}
}
agent {
docker {
image 'node:8.11.3'
}
}
steps {
script {
sh '''npm prune
npm install
chmod +x ./scripts/build.sh
chmod +x ./scripts/deploy.sh
./scripts/build.sh
./scripts/deploy.sh'''
}
}
}
}
environment {
GH_REPO = 'https://github.com/entrylabs/entryjs.git'
GH_REF = 'github.com/entrylabs/entryjs.git'
}
}