This repository has been archived by the owner on Nov 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Jenkinsfile
221 lines (182 loc) · 8.73 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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#!groovy
pipeline {
agent any
tools {
jdk 'oracle-jdk8-latest'
}
options {
timestamps()
skipStagesAfterUnstable()
timeout(time: 2, unit: 'HOURS')
}
triggers {
upstream(upstreamProjects: "Codewind/codewind-installer/${env.BRANCH_NAME}", threshold: hudson.model.Result.SUCCESS)
}
parameters {
string(name: "APPSODY_VERSION", defaultValue: "0.6.4", description: "Appsody executable version to download")
}
stages {
stage("Download dependency binaries") {
steps {
dir("dev/org.eclipse.codewind.core/binaries") {
sh """#!/usr/bin/env bash
export VSCODE_REPO="https://github.com/eclipse/codewind-vscode.git"
export CW_VSCODE_BRANCH=master
# the command below will echo the head commit if the branch exists, else it just exits
if [[ -n \$(git ls-remote --heads \$VSCODE_REPO ${env.BRANCH_NAME}) ]]; then
echo "Will pull scripts from matching ${env.BRANCH_NAME} branch on \$VSCODE_REPO"
export CW_VSCODE_BRANCH=${env.BRANCH_NAME}
else
echo "Will pull scripts from \$CW_VSCODE_BRANCH branch on \$VSCODE_REPO - no matching branch"
fi
export INSTALLER_REPO="https://github.com/eclipse/codewind-installer.git"
export CW_CLI_BRANCH=master
# the command below will echo the head commit if the branch exists, else it just exits
if [[ -n \$(git ls-remote --heads \$INSTALLER_REPO ${env.BRANCH_NAME}) ]]; then
echo "Will pull binaries from matching ${env.BRANCH_NAME} branch on \$INSTALLER_REPO"
export CW_CLI_BRANCH=${env.BRANCH_NAME}
else
echo "Will pull binaries from \$CW_CLI_BRANCH branch on \$INSTALLER_REPO - no matching branch"
fi
export APPSODY_VERSION=${params.APPSODY_VERSION}
./meta-pull.sh
./pull.sh
"""
}
}
}
stage("Create install-version.properties") {
steps {
sh """
dev/set-install-version.sh ${env.BRANCH_NAME} dev/org.eclipse.codewind.core/resources
"""
}
}
stage('Build') {
steps {
script {
println("Starting codewind-eclipse build ...")
def sys_info = sh(script: "uname -a", returnStdout: true).trim()
println("System information: ${sys_info}")
println("JAVE_HOME: ${JAVA_HOME}")
sh '''
java -version
which java
'''
dir('dev') { sh './gradlew --stacktrace' }
dir('dev/ant_build/artifacts') {
stash name: 'codewind_test.zip', includes: 'codewind_test-*.zip'
sh 'rm codewind_test-*.zip'
stash name: 'codewind.zip', includes: 'codewind-*.zip'
}
}
}
}
stage('Test filewatcher') {
steps {
dir("dev") {
sh """#!/usr/bin/env bash
export CHANGE_TARGET=\$CHANGE_TARGET
cd org.eclipse.codewind.filewatchers.standalonenio
./run_fwd_tests_if_needed.sh
"""
}
}
}
stage('Test') {
options {
timeout(time: 1, unit: "HOURS")
}
agent {
label "docker-build"
}
steps {
script {
try {
dir('dev/ant_build/artifacts') {
unstash 'codewind_test.zip'
unstash 'codewind.zip'
}
sh '''#!/usr/bin/env bash
echo "Git commit is: $(git log --format=medium -1 ${GIT_COMMIT})"
./dev/run.sh
'''
} finally {
junit 'dev/junit-results.xml'
}
}
}
post {
always {
sh '''#!/usr/bin/env bash
# Docker system prune
echo "Docker system prune ..."
docker system df
echo "First remove containers ..."
if [[ $(docker ps -a -q | wc -l) -gt 0 ]]; then
docker rm -f $(docker ps -a -q)
fi
docker system prune -a --volumes -f
docker builder prune -a -f
docker system df
df -lh
'''
}
}
}
stage('Deploy') {
steps {
sshagent ( ['projects-storage.eclipse.org-bot-ssh']) {
println("Deploying codewind-eclipse to downoad area...")
sh '''
export REPO_NAME="codewind-eclipse"
export OUTPUT_NAME="codewind"
export OUTPUT_DIR="$WORKSPACE/dev/ant_build/artifacts"
export DOWNLOAD_AREA_URL="https://archive.eclipse.org/codewind/$REPO_NAME"
export LATEST_DIR="latest"
export BUILD_INFO="build_info.properties"
export sshHost="[email protected]"
export deployDir="/home/data/httpd/archive.eclipse.org/codewind/$REPO_NAME"
if [ -z $CHANGE_ID ]; then
UPLOAD_DIR="$GIT_BRANCH/$BUILD_ID"
BUILD_URL="$DOWNLOAD_AREA_URL/$UPLOAD_DIR"
ssh $sshHost rm -rf $deployDir/$GIT_BRANCH/$LATEST_DIR
ssh $sshHost mkdir -p $deployDir/$GIT_BRANCH/$LATEST_DIR
cp $OUTPUT_DIR/$OUTPUT_NAME-*.zip $OUTPUT_DIR/$OUTPUT_NAME.zip
scp $OUTPUT_DIR/$OUTPUT_NAME.zip $sshHost:$deployDir/$GIT_BRANCH/$LATEST_DIR/$OUTPUT_NAME.zip
echo "# Build date: $(date +%F-%T)" >> $OUTPUT_DIR/$BUILD_INFO
echo "build_info.url=$BUILD_URL" >> $OUTPUT_DIR/$BUILD_INFO
SHA1=$(sha1sum ${OUTPUT_DIR}/${OUTPUT_NAME}.zip | cut -d ' ' -f 1)
echo "build_info.SHA-1=${SHA1}" >> $OUTPUT_DIR/$BUILD_INFO
unzip $OUTPUT_DIR/$OUTPUT_NAME-*.zip -d $OUTPUT_DIR/repository
scp -r $OUTPUT_DIR/repository $sshHost:$deployDir/$GIT_BRANCH/$LATEST_DIR/repository
scp $OUTPUT_DIR/$BUILD_INFO $sshHost:$deployDir/$GIT_BRANCH/$LATEST_DIR/$BUILD_INFO
rm $OUTPUT_DIR/$BUILD_INFO
rm $OUTPUT_DIR/$OUTPUT_NAME.zip
rm -rf $OUTPUT_DIR/repository
else
UPLOAD_DIR="pr/$CHANGE_ID/$BUILD_ID"
fi
ssh $sshHost rm -rf $deployDir/${UPLOAD_DIR}
ssh $sshHost mkdir -p $deployDir/${UPLOAD_DIR}
scp -r $OUTPUT_DIR/* $sshHost:$deployDir/${UPLOAD_DIR}
'''
}
}
}
stage("Report") {
when {
beforeAgent true
triggeredBy 'UpstreamCause'
}
options {
skipDefaultCheckout()
}
steps {
mail to: '[email protected], [email protected]',
subject: "${currentBuild.currentResult}: Upstream triggered build for ${currentBuild.fullProjectName}",
body: "${currentBuild.absoluteUrl}\n${currentBuild.getBuildCauses()[0].shortDescription} had status ${currentBuild.currentResult}"
}
}
}
}