-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
115 lines (115 loc) · 2.89 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
pipeline {
agent {
kubernetes {
yamlFile 'kubernetesPod.yaml'
defaultContainer 'rdepot-client-build'
}
}
options {
buildDiscarder(logRotator(numToKeepStr: '3'))
}
environment {
VERSION = sh(returnStdout: true, script: 'node -p "require(\'./package.json\').version"').trim()
NS = 'openanalytics'
REGISTRY = 'registry.openanalytics.eu'
IMAGE = 'rdepot-client'
CACHE_IMAGE = 'rdepot-client-cache'
DOCKER_BUILDKIT = '1'
NO_COLOR = 'true'
}
stages {
stage('Prepare Environment') {
steps {
script {
if (env.BRANCH_NAME == 'develop') {
env.TAG = "${env.VERSION}-SNAPSHOT"
} else {
env.TAG = "${env.VERSION}"
}
echo "TAG is set to ${env.TAG}"
}
}
}
stage('Install Dependencies') {
steps {
sh "npm install"
}
}
stage('License Check') {
steps {
sh "npm run license:check"
}
}
stage('Linting') {
steps {
sh "npm run lint:check"
withChecks('Linting') {
junit "reports/lint-report.xml"
}
publishHTML([
reportDir: 'reports', reportFiles: 'lint-report.html',
reportName: 'UI Linting Report',
allowMissing: true, alwaysLinkToLastBuild: true, keepAll: true])
}
}
stage('Build') {
steps {
container('kaniko') {
sh """
/kaniko/executor \
-v info \
--context ${env.WORKSPACE} \
--cache=true \
--cache-repo ${env.REGISTRY}/${env.NS}/${env.CACHE_IMAGE} \
--no-push
"""
}
}
}
stage('Unit Tests') {
steps {
sh "npm run test:unit:once:junit"
withChecks('UI Unit Tests') {
junit "reports/test-report-unit.xml"
}
}
}
stage('Integration Tests') {
steps {
withDockerRegistry([
credentialsId: "oa-sa-jenkins-registry",
url: "https://registry.openanalytics.eu"]){
sh """
npm run test:setup
npm run test:integration:once:junit
npm run test:cleanup
"""
withChecks('UI Integration Tests') {
junit "reports/test-report-integration.xml"
}
}
}
}
stage('Publish') {
when {
anyOf {
branch 'develop'
branch 'master'
branch 'main'
}
}
steps {
container('kaniko') {
sh """
/kaniko/executor \
-v info \
--context ${env.WORKSPACE} \
--cache=true \
--cache-repo ${env.REGISTRY}/${env.NS}/${env.CACHE_IMAGE} \
--destination ${env.REGISTRY}/${env.NS}/${env.IMAGE}:${env.TAG}
"""
}
}
}
}
}