-
Notifications
You must be signed in to change notification settings - Fork 14
/
eap-job-64.sh
executable file
·255 lines (212 loc) · 9.17 KB
/
eap-job-64.sh
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
#!/bin/bash
#
#
# Build Wildlfy/EAP
#
set -eo pipefail
usage() {
local -r script_name=$(basename "${0}")
echo "${script_name} <build|testsuite> [extra-args]"
echo
echo "ex: ${script_name} 'testsuite' -Dcustom.args"
echo
echo "Note that if no arguments are provided, it defaults to 'build'. To run the testsuite, you need to provide 'testsuite' as the first argument. All arguments beyond this first will be appended to the mvn command line."
echo
echo 'Warning: This script also sets several mvn args. Please refer to its content before adding some extra maven arguments.'
}
is_dirpath_defined_and_exists() {
local dir_path=${1}
local var_name=${2}
if [ "${dir_path}" = '' ]; then
echo "Directory path provided by ${var_name} is not set."
return 1
fi
if [ ! -d "${dir_path}" ]; then
echo "Following dir_path does not exists: ${dir_path}."
return 2
fi
}
record_build_properties() {
readonly PROPERTIES_FILE='umb-build.properties'
readonly EAP_VERSION=$(grep -r '<full.dist.product.release.version>' "$EAP_SOURCES_DIR/pom.xml" | sed 's/.*>\(.*\)<.*/\1/')
echo "BUILD_URL=${BUILD_URL}" >> ${PROPERTIES_FILE}
echo "SERVER_URL=${BUILD_URL}/artifact/jboss-eap-dist-${GIT_COMMIT:0:7}.zip" >> ${PROPERTIES_FILE}
echo "SOURCE_URL=${BUILD_URL}/artifact/jboss-eap-src-${GIT_COMMIT:0:7}.zip" >> ${PROPERTIES_FILE}
echo "VERSION=${EAP_VERSION}-${GIT_COMMIT:0:7}" >> ${PROPERTIES_FILE}
echo "BASE_VERSION=${EAP_VERSION}" >> ${PROPERTIES_FILE}
echo "BUILD_ID=${BUILD_ID}" >> ${PROPERTIES_FILE}
echo "SCM_URL=${GIT_URL}" >> ${PROPERTIES_FILE}
echo "SCM_REVISION=${GIT_COMMIT}" >> ${PROPERTIES_FILE}
cat ${PROPERTIES_FILE}
}
function get_eap_version() {
eap_version=$(xmllint pom.xml --xpath "//*[local-name()='project']/*[local-name()='properties']/*[local-name()='jboss.eap.release.version']/text()")
if [ -z "${eap_version}" ] && [ -f build/src/main/resources/version.txt ]; then
eap_version=$(cat build/src/main/resources/version.txt | egrep -o '([[:digit:]])\.[[:digit:]]')
fi
echo $eap_version;
}
function debug_script() {
if [ -z "${DEBUG}" ] ; then
echo ""
else
echo '-x'
fi
}
BUILD_COMMAND=${1}
if [ "${BUILD_COMMAND}" = '--help' ] || [ "${BUILD_COMMAND}" = '-h' ]; then
usage
exit 0
fi
if [ "${BUILD_COMMAND}" != 'build' ] && [ "${BUILD_COMMAND}" != 'testsuite' ]; then
readonly BUILD_COMMAND='build'
else
readonly BUILD_COMMAND="${BUILD_COMMAND}"
shift
fi
readonly MAVEN_VERBOSE=${MAVEN_VERBOSE}
# ensure provided JAVA_HOME, if any, is first in PATH
if [ -n "${JAVA_HOME}" ]; then
export PATH=${JAVA_HOME}/bin:${PATH}
fi
if [ -n "${IS_CCI}" ]; then
readonly EAP_SOURCES_FOLDER=${EAP_SOURCES_FOLDER:-"eap-sources"}
readonly EAP_SOURCES_DIR=${EAP_SOURCES_DIR:-"${WORKSPACE}/${EAP_SOURCES_FOLDER}"}
else
readonly EAP_SOURCES_DIR=${EAP_SOURCES_DIR:-"${WORKSPACE}"}
fi
readonly GIT_SKIP_BISECT_ERROR_CODE=${GIT_SKIP_BISECT_ERROR_CODE:-'125'}
readonly MEMORY_SETTINGS=${MEMORY_SETTINGS:-''}
readonly LOCAL_REPO_DIR=${LOCAL_REPO_DIR:-${WORKSPACE}/maven-local-repository}
export BUILD_OPTS=${BUILD_OPTS:-'-Drelease'}
readonly MAVEN_WAGON_HTTP_POOL=${WAGON_HTTP_POOL:-'false'}
readonly MAVEN_WAGON_HTTP_MAX_PER_ROUTE=${MAVEN_WAGON_HTTP_MAX_PER_ROUTE:-'3'}
readonly SUREFIRE_FORKED_PROCESS_TIMEOUT=${SUREFIRE_FORKED_PROCESS_TIMEOUT:-'90000'}
readonly FAIL_AT_THE_END=${FAIL_AT_THE_END:-'-fae'}
readonly RERUN_FAILING_TESTS=${RERUN_FAILING_TESTS:-'0'}
readonly DIST_FOLDER=${DIST_FOLDER:-'dist/target'}
readonly OLD_RELEASES_FOLDER=${OLD_RELEASES_FOLDER:-/opt/old-as-releases}
readonly FOLDER_DOES_NOT_EXIST_ERROR_CODE='3'
readonly ZIP_WORKSPACE=${ZIP_WORKSPACE:-'false'}
if [ -n "${EXECUTOR_NUMBER}" ]; then
echo -n "Job run by executor ID ${EXECUTOR_NUMBER} "
fi
if [ -n "${WORKSPACE}" ]; then
echo -n "inside workspace: ${WORKSPACE}"
fi
echo '.'
if [ -z "${MAVEN_HOME}" ] || [ ! -e "${MAVEN_HOME}/bin/mvn" ]; then
echo "No Maven Home defined - setting to default: ${DEFAULT_MAVEN_HOME}"
export MAVEN_HOME=${DEFAULT_MAVEN_HOME}
if [ ! -d "${DEFAULT_MAVEN_HOME}" ]; then
echo "No maven install found (${DEFAULT_MAVEN_HOME}) - downloading one:"
cd "$(pwd)/tools" || exit "${FOLDER_DOES_NOT_EXIST_ERROR_CODE}"
MAVEN_HOME="$(pwd)/maven"
export MAVEN_HOME
export PATH=${MAVEN_HOME}/bin:${PATH}
bash ./download-maven.sh
chmod +x ./*/bin/*
cd - || exit "${FOLDER_DOES_NOT_EXIST_ERROR_CODE}"
fi
command -v mvn
mvn -version
fi
readonly MAVEN_BIN_DIR=${MAVEN_HOME}/bin
echo "Adding ${MAVEN_BIN_DIR} to PATH:${PATH}."
export PATH=${MAVEN_BIN_DIR}:${PATH}
# Check Maven version and perform the maven setup accordingly.
readonly MAVEN_VERSION=$(mvn -v | awk '/Apache Maven/ {print $3}')
function maven_setup() {
if [ "${MAVEN_VERSION}" != "3.2.5" ]; then
# with EAP 6.4, let maven 3.2 be downloaded to the tools/maven/ directory, which is a hardcoded path in the integration-tests.sh script
cd "${EAP_SOURCES_DIR}"
bash $(debug_script) ./tools/download-maven.sh
fi
}
command -v java
java -version
# shellcheck disable=SC2181
if [ "${?}" -ne 0 ]; then
echo "No JVM provided - aborting..."
exit 1
fi
mkdir -p "${LOCAL_REPO_DIR}"
export MAVEN_OPTS="${MAVEN_OPTS} ${MEMORY_SETTINGS}"
# workaround wagon isseu - https://projects.engineering.redhat.com/browse/SET-20
export MAVEN_OPTS="${MAVEN_OPTS} -Dmaven.wagon.http.pool=${MAVEN_WAGON_HTTP_POOL}"
export MAVEN_OPTS="${MAVEN_OPTS} -Dmaven.wagon.httpconnectionManager.maxPerRoute=${MAVEN_WAGON_HTTP_MAX_PER_ROUTE}"
# using project's maven repository
export MAVEN_OPTS="${MAVEN_OPTS} -Dmaven.repo.local=${LOCAL_REPO_DIR}"
if [ -n "${MAVEN_SETTINGS_XML}" ] && [ "${MAVEN_SETTINGS_XML}" != "none" ]; then
readonly MAVEN_SETTINGS_XML_OPTION="-s ${MAVEN_SETTINGS_XML}"
else
readonly MAVEN_SETTINGS_XML_OPTION=''
fi
unset JBOSS_HOME
if [ "${BUILD_COMMAND}" = 'build' ]; then
if [ -n "${IS_CCI}" ]; then
zip -qr "jboss-eap-src-${GIT_COMMIT:0:7}.zip" "${EAP_SOURCES_FOLDER}"
cd "${EAP_SOURCES_DIR}" || exit "${FOLDER_DOES_NOT_EXIST_ERROR_CODE}"
fi
# configure product repository URL used by tests
export BUILD_OPTS="${BUILD_OPTS} -Dorg.jboss.model.test.maven.repository.urls=http://download.lab.bos.redhat.com/brewroot/repos/jb-eap-6.4-rhel-6-build/latest/maven/,https://repository.jboss.org/nexus/content/repositories/releases/"
maven_setup
# shellcheck disable=SC2086,SC2068
bash $(debug_script) ./build.sh ${MAVEN_VERBOSE} "${FAIL_AT_THE_END}" ${MAVEN_SETTINGS_XML_OPTION} -B ${BUILD_OPTS} ${@}
status=${?}
if [ "${status}" -ne 0 ]; then
echo "Compilation failed"
exit "${GIT_SKIP_BISECT_ERROR_CODE}"
fi
if [ "${ZIP_WORKSPACE}" == "true" ]; then
zip -x "${HARMONIA_FOLDER}" -x \*.zip -qr 'workspace.zip' "${WORKSPACE}"
fi
if [ -n "${IS_CCI}" ]; then
readonly EAP_DIST_DIR="${DIST_FOLDER}"
echo "Using ${EAP_DIST_DIR}"
cd "${EAP_DIST_DIR}" || exit "${FOLDER_DOES_NOT_EXIST_ERROR_CODE}"
zip -qr "${WORKSPACE}/jboss-eap-dist-${GIT_COMMIT:0:7}.zip" jboss-eap-*
cd "${LOCAL_REPO_DIR}/.." || exit "${FOLDER_DOES_NOT_EXIST_ERROR_CODE}"
zip -qr "${WORKSPACE}/jboss-eap-maven-artifacts-${GIT_COMMIT:0:7}.zip" "maven-local-repository"
cd "${WORKSPACE}"
record_build_properties
fi
else
if ! is_dirpath_defined_and_exists "${OLD_RELEASES_FOLDER}" 'OLD_RELEASES_FOLDER'; then
echo "Invalid directory for old_releases: ${OLD_RELEASES_FOLDER}. Testsuite will fails to run, aborting."
exit 3
fi
if [ -n "${IS_CCI}" ]; then
# unzip artifacts from build job
find . -maxdepth 1 -name '*.zip' -exec unzip -q {} \;
for file in jboss-eap-6.[0-9]*.zip; do unzip "$file"; done
TEST_JBOSS_DIST=$(find . -regextype posix-extended -regex '.*jboss-eap-6\.[0-9]+')
if [ -z "$TEST_JBOSS_DIST" ]; then
echo "No EAP distribution to be tested"
exit 2
else
export TESTSUITE_OPTS="${TESTSUITE_OPTS} -Djboss.dist=${WORKSPACE}/${TEST_JBOSS_DIST}"
fi
if [ "${ip}" == "ipv6" ];
then
export TESTSUITE_OPTS="${TESTSUITE_OPTS} -Dipv6"
fi
fi
unset JBOSS_HOME
export TESTSUITE_OPTS="${TESTSUITE_OPTS} -Dsurefire.forked.process.timeout=${SUREFIRE_FORKED_PROCESS_TIMEOUT}"
export TESTSUITE_OPTS="${TESTSUITE_OPTS} -Dskip-download-sources -B"
export TESTSUITE_OPTS="${TESTSUITE_OPTS} -Djboss.test.mixed.domain.dir=${OLD_RELEASES_FOLDER}"
export TESTSUITE_OPTS="${TESTSUITE_OPTS} -Dmaven.test.failure.ignore=${MAVEN_IGNORE_TEST_FAILURE}"
export TESTSUITE_OPTS="${TESTSUITE_OPTS} -Dsurefire.rerunFailingTestsCount=${RERUN_FAILING_TESTS}"
export TESTSUITE_OPTS="${TESTSUITE_OPTS} -Dsurefire.memory.args=-Xmx4048m"
export TESTSUITE_OPTS="${TESTSUITE_OPTS} ${MAVEN_SETTINGS_XML_OPTION}"
export TEST_TO_RUN=${TEST_TO_RUN:-'-DallTests'}
maven_setup
# define this var so that integration-tests.sh doesn't use its hardcoded default value
export MVN_ARGS="-DsomeNoneEmptyValue"
# configure product repository URL used by integration tests
export TESTSUITE_OPTS="${TESTSUITE_OPTS} -Dorg.jboss.model.test.eap.repourl=http://download.lab.bos.redhat.com/brewroot/repos/jb-eap-6.4-rhel-6-build/latest/maven/"
# shellcheck disable=SC2086,SC2068
bash $(debug_script) ./integration-tests.sh "${TEST_TO_RUN}" ${MAVEN_VERBOSE} "${FAIL_AT_THE_END}" ${TESTSUITE_OPTS} ${@}
exit "${?}"
fi