-
Notifications
You must be signed in to change notification settings - Fork 17
/
Jenkinsfile
201 lines (171 loc) · 6.68 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!groovy
pipeline {
agent {
kubernetes {
label 'filewatcherd-buildpod'
yaml """
apiVersion: v1
kind: Pod
spec:
containers:
- name: filewatcherd-ts-builder
image: node:lts
tty: true
command:
- cat
resources:
limits:
memory: "2Gi"
cpu: "1"
requests:
memory: "2Gi"
cpu: "1"
- name: go
image: golang:1.12-stretch
tty: true
command:
- cat
resources:
limits:
memory: "2Gi"
cpu: "1"
requests:
memory: "2Gi"
cpu: "1"
"""
}
}
options {
timestamps()
skipStagesAfterUnstable()
}
environment {
// https://stackoverflow.com/a/43264045
HOME="."
}
stages {
stage('Build TypeScript Filewatcher') {
options {
timeout(time: 30, unit: 'MINUTES')
}
steps {
container("filewatcherd-ts-builder") {
dir ("Filewatcherd-TypeScript") {
sh '''#!/usr/bin/env bash
./npm-package.sh
'''
stash includes: "filewatcherd*.tar.gz", name: "output"
}
}
}
}
stage('Run tests') {
options {
timeout(time: 120, unit: 'MINUTES')
}
steps {
container("go") {
dir ("Tests") {
sh '''#!/usr/bin/env bash
set -euo pipefail
echo
echo "Download Java and add to path"
echo
export STEP_ROOT_PATH=`pwd`
curl -LO https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u242-b08_openj9-0.18.1/OpenJDK8U-jdk_x64_linux_openj9_8u242b08_openj9-0.18.1.tar.gz
tar xzf OpenJDK8U-jdk_x64_linux_openj9_8u242b08_openj9-0.18.1.tar.gz
cd jdk8u242-b08
export JAVA_HOME=`pwd`
cd bin/
export PATH=`pwd`:$PATH
echo
echo "Download Maven and add to path"
echo
cd $STEP_ROOT_PATH
curl -LO http://mirror.dsrg.utoronto.ca/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
tar xzf apache-maven-3.6.3-bin.tar.gz
cd apache-maven-3.6.3/bin
export PATH=`pwd`:$PATH
echo
echo "Run Go tests"
echo
cd $STEP_ROOT_PATH/
./run_tests_go_filewatcher.sh
'''
}
}
container("filewatcherd-ts-builder") {
dir ("Tests") {
sh '''#!/usr/bin/env bash
set -euo pipefail
echo
echo "Download Java and add to path"
echo
export STEP_ROOT_PATH=`pwd`
curl -LO https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u242-b08_openj9-0.18.1/OpenJDK8U-jdk_x64_linux_openj9_8u242b08_openj9-0.18.1.tar.gz
tar xzf OpenJDK8U-jdk_x64_linux_openj9_8u242b08_openj9-0.18.1.tar.gz
cd jdk8u242-b08
export JAVA_HOME=`pwd`
cd bin/
export PATH=`pwd`:$PATH
echo
echo "Download Maven and add to path"
echo
cd $STEP_ROOT_PATH
curl -LO http://mirror.dsrg.utoronto.ca/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
tar xzf apache-maven-3.6.3-bin.tar.gz
cd apache-maven-3.6.3/bin
export PATH=`pwd`:$PATH
echo
echo "Run Node tests"
echo
cd $STEP_ROOT_PATH/
./run_tests_node_filewatcher.sh
'''
}
}
}
}
stage('Deploy') {
// This when clause disables PR build uploads; you may comment this out if you want your build uploaded.
when {
beforeAgent true
not {
changeRequest()
}
}
options {
skipDefaultCheckout()
timeout(time: 120, unit: 'MINUTES')
retry(3)
}
agent any
steps {
sshagent (['projects-storage.eclipse.org-bot-ssh']) {
println("Deploying codewind-filewatchers to download area...")
unstash "output"
sh '''
export SSH_HOST="genie.codewind@projects-storage.eclipse.org"
export TARGET_DIR_PARENT="/home/data/httpd/archive.eclipse.org/codewind/codewind-filewatcher-ts/${GIT_BRANCH}/"
export TARGET_DIR="${TARGET_DIR_PARENT}/${BUILD_ID}"
export LATEST_DIR="${TARGET_DIR_PARENT}/latest"
export ARTIFACT_NAME="$(basename "filewatcherd*.tar.gz")"
export LATEST_ARTIFACT_NAME="filewatcherd-node_latest.tar.gz"
export BUILD_INFO="build_info.properties"
echo "# Build date: $(date +%F-%T)" >> $BUILD_INFO
echo "build_info.url=$BUILD_URL" >> $BUILD_INFO
SHA1=$(sha1sum ${ARTIFACT_NAME} | cut -d ' ' -f 1)
echo "build_info.SHA-1=${SHA1}" >> $BUILD_INFO
set -x
ssh $SSH_HOST mkdir -p $TARGET_DIR
scp $ARTIFACT_NAME ${SSH_HOST}:${TARGET_DIR}
cp -v $ARTIFACT_NAME $LATEST_ARTIFACT_NAME
ssh $SSH_HOST mkdir -p $LATEST_DIR
scp $LATEST_ARTIFACT_NAME ${SSH_HOST}:${LATEST_DIR}
scp $BUILD_INFO ${SSH_HOST}:${LATEST_DIR}
'''
}
}
}
}
}