blob: b021b9bf94e87fd56b3164e4663d3dd999cd0847 (
plain)
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
|
#!/bin/bash
set -euf -o pipefail
# shellcheck source=jenkins-helpers.sh
. "$(dirname $0)"/jenkins-helpers.sh
convert_args_to_variables "$@"
shift "$SHIFT_CONVERTED_ARGS"
qemu="${qemu-}"
WORKSPACE="${WORKSPACE-}"
prefix="${prefix-}"
case "$qemu" in
"") "$(dirname $0)"/start-container-docker.sh "${CONVERTED_ARGS[@]:1}" > container.sh ;;
*) "$(dirname $0)"/start-container-qemu.sh "${CONVERTED_ARGS[@]:1}" > container.sh ;;
esac
# Where prefix is something like "run_" or "test_".
# We ignore cleanup failures and exit with the original status code.
# shellcheck disable=SC2064 disable=SC2154
trap "res=\$?; ${prefix}container_cleanup & wait \$! || true; exit \$res" EXIT
. ./container.sh
# We want to use flock only when WORKSPACE exists
if [ "x$WORKSPACE" != "x" ]; then
if [ ! -d "$WORKSPACE" ]; then
echo "ERROR: WORKSPACE $WORKSPACE does not exist"
exit 1
fi
JENKINS_FLOCK="flock $WORKSPACE"
else
# Used by remote_exec later
# shellcheck disable=SC2034
JENKINS_FLOCK=""
fi
${prefix}container_exec "$@"
|