This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathJenkinsfile
executable file
·132 lines (107 loc) · 3.63 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!groovy
// https://github.com/feedhenry/fh-pipeline-library
@Library('fh-pipeline-library') _
stage('Trust') {
enforceTrustedApproval()
}
fhBuildNode([labels: ['nodejs6']]) {
String fhMessagingVersion = null
String fhMetricsVersion = null
final String BUILD = env.BUILD_NUMBER
final String DOCKER_HUB_ORG = "feedhenry"
final String CHANGE_URL = env.CHANGE_URL
stage('Install Dependencies') {
dir('fh-messaging') {
fhMessagingVersion = getBaseVersionFromPackageJson()
npmInstall {}
}
dir('fh-metrics') {
fhMetricsVersion = getBaseVersionFromPackageJson()
npmInstall {}
}
}
stage('Lint') {
dir('fh-messaging') {
sh "grunt eslint"
}
dir('fh-metrics') {
sh "grunt eslint"
}
}
withOpenshiftServices(['mongodb32']) {
stage('Unit Tests') {
dir('fh-messaging') {
sh "grunt fh-unit"
}
dir('fh-metrics') {
sh "grunt fh-unit"
}
}
stage('Acceptance Tests') {
dir('fh-messaging') {
sh "grunt fh-accept"
}
dir('fh-metrics') {
sh "grunt fh-accept"
}
}
stage('Integration Tests') {
dir('fh-messaging') {
sh "npm install -g"
sh "cp -R config /tmp/fh-messaging-config"
sh """
cat /tmp/fh-messaging-config/dev.json | \
jq '.database.host="${env.MONGODB_HOST}"' | \
jq '.metrics.database.host="${env.MONGODB_HOST}"' | \
jq '.metrics.metricsDir="/tmp/var/log/feedhenry/fh-messaging/metrics"' | \
jq '.configDir="/tmp/fh-messaging-config/"' > \
/tmp/fh-messaging-config/conf.json
"""
sh "cp /tmp/fh-messaging-config/conf.json config/dev.json"
sh "mkdir -p /tmp/var/log/feedhenry/fh-messaging/metrics"
sh "grunt fh-integrate"
}
dir('fh-metrics') {
sh "grunt fh-integrate"
}
}
}
stage('Build') {
dir('fh-messaging') {
sh 'grunt fh:dist --only-bundle-deps'
}
dir('fh-metrics') {
sh 'grunt fh:dist --only-bundle-deps'
}
String buildInfoFileName = 'build-info.json'
dir('dist') {
buildInfoFileName = writeBuildInfo('fh-messaging', fhMessagingVersion)
writeBuildInfo('fh-metrics', fhMetricsVersion)
sh "cp ../fh-messaging/dist/fh-messaging*.tar.gz ."
sh "cp ../fh-metrics/dist/fh-metrics*.tar.gz ."
}
archiveArtifacts "dist/${buildInfoFileName}"
}
stage('Platform Update') {
final Map updateParams = [
componentName: 'fh-messaging',
componentVersion: fhMessagingVersion,
componentBuild: BUILD,
changeUrl: CHANGE_URL
]
fhOpenshiftTemplatesComponentUpdate(updateParams)
fhCoreOpenshiftTemplatesComponentUpdate(updateParams)
updateParams.componentName = 'fh-metrics'
updateParams.componentVersion = fhMetricsVersion
fhOpenshiftTemplatesComponentUpdate(updateParams)
fhCoreOpenshiftTemplatesComponentUpdate(updateParams)
}
stage('Build Image') {
dir('fh-messaging') {
dockerBuildNodeComponent('fh-messaging', DOCKER_HUB_ORG)
}
dir('fh-metrics') {
dockerBuildNodeComponent('fh-metrics', DOCKER_HUB_ORG)
}
}
}