Skip to content
This repository was archived by the owner on Nov 28, 2022. It is now read-only.

Commit 95467b3

Browse files
josephcasghung
authored andcommitted
Add test codes and fix the build failure (#117)
* update run*.sh * use docker agent * removed println for unavilable JAVA_HOME * stash output * add test * Fix typo * Update * Update
1 parent 99a3576 commit 95467b3

3 files changed

Lines changed: 61 additions & 18 deletions

File tree

Jenkinsfile

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
#!groovy​
22

33
pipeline {
4-
agent any
5-
6-
tools {
7-
jdk 'oracle-jdk8-latest'
4+
agent {
5+
label "docker-build"
86
}
9-
7+
108
options {
119
timestamps()
1210
skipStagesAfterUnstable()
@@ -21,23 +19,60 @@ pipeline {
2119

2220
def sys_info = sh(script: "uname -a", returnStdout: true).trim()
2321
println("System information: ${sys_info}")
24-
println("JAVE_HOME: ${JAVA_HOME}")
2522

2623
sh '''
2724
java -version
2825
which java
2926
'''
3027

31-
dir('dev') { sh './gradlew --stacktrace' }
28+
dir('dev') {
29+
sh './gradlew --stacktrace'
30+
}
3231
}
3332
}
3433
}
34+
35+
stage('Test') {
36+
steps {
37+
script {
38+
sh '''#!/usr/bin/env bash
39+
docker build --no-cache -t test-image ./dev
40+
export CWD=$(pwd)
41+
echo "Current directory is ${CWD}"
42+
docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${CWD}/dev:/development test-image
43+
44+
rm $WORKSPACE/dev/ant_build/artifacts/codewind-openapi-eclipse-test-*.zip
45+
'''
46+
dir('dev') {
47+
stash name: 'codewind-openapi-eclipse-zip', includes: 'ant_build/artifacts/codewind-openapi-eclipse-*.zip'
48+
}
49+
}
50+
}
51+
}
3552

3653
stage('Deploy') {
54+
// This when clause disables PR build uploads; you may comment this out if you want your build uploaded.
55+
when {
56+
beforeAgent true
57+
not {
58+
changeRequest()
59+
}
60+
}
61+
62+
options {
63+
skipDefaultCheckout()
64+
}
65+
66+
agent any
67+
3768
steps {
3869
sshagent ( ['projects-storage.eclipse.org-bot-ssh']) {
3970
println("Deploying codewind-openapi-eclipse to downoad area...")
40-
71+
72+
dir("$WORKSPACE/dev") {
73+
unstash 'codewind-openapi-eclipse-zip'
74+
}
75+
4176
sh '''
4277
export REPO_NAME="codewind-openapi-eclipse"
4378
export OUTPUT_NAME="codewind-openapi-eclipse"
@@ -48,8 +83,6 @@ pipeline {
4883
export sshHost="genie.codewind@projects-storage.eclipse.org"
4984
export deployDir="/home/data/httpd/download.eclipse.org/codewind/$REPO_NAME"
5085
51-
rm $OUTPUT_DIR/$REPO_NAME-test-*.zip
52-
5386
if [ -z $CHANGE_ID ]; then
5487
UPLOAD_DIR="$GIT_BRANCH/$BUILD_ID"
5588
BUILD_URL="$DOWNLOAD_AREA_URL/$UPLOAD_DIR"
@@ -81,5 +114,19 @@ pipeline {
81114
}
82115
}
83116
}
84-
}
117+
}
118+
119+
post {
120+
always {
121+
sh '''#!/usr/bin/env bash
122+
# Docker system prune
123+
echo "Docker system prune ..."
124+
docker system df
125+
docker system prune -a --volumes -f
126+
docker builder prune -a -f
127+
docker system df
128+
df -lh
129+
'''
130+
}
131+
}
85132
}

dev/run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ xvfb-run ./runTest.sh
2828

2929
return_code=$?
3030

31-
echo "Copying test result to results.xml"
32-
cp /tmp/results.xml /development/results.xml
31+
echo "Test result filer is: /development/junit-results.xml"
32+
ls -l /development
3333

3434
echo "Test finished with return code $return_code"
3535
return $return_code

dev/runTest.sh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ fi
1919

2020
export ADDITIONAL_ENV_VARS="-Duser.timezone=America/Toronto $ADDITIONAL_ENV_VARS"
2121

22-
if [ "$run_on_ui_thread" == "true" ]; then
23-
export APPLICATION_TYPE=org.eclipse.test.uitestapplication
24-
fi
25-
2622
echo TEST CLASS NAME is $TEST_CLASS_NAME
2723
echo TEST PLUG-IN NAME is $TEST_PLUGIN_NAME
2824
echo APPLICATION_TYPE is $APPLICATION_TYPE
@@ -54,7 +50,7 @@ $ADDITIONAL_ENV_VARS \
5450
-application $APPLICATION_TYPE \
5551
-data /tmp/workspace-location \
5652
-testPluginName $TEST_PLUGIN_NAME \
57-
-className $TEST_CLASS_NAME formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,/tmp/results.xml \
53+
-className $TEST_CLASS_NAME formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,/development/junit-results.xml \
5854
-vmargs \
5955
-Xms256m \
6056
-Xmx1024m \

0 commit comments

Comments
 (0)