Skip to content

Commit

Permalink
Refactor build.sh init and include SHELL_ON_ERRORS (#1191)
Browse files Browse the repository at this point in the history
Signed-off-by: Jose Luis Rivero <[email protected]>
  • Loading branch information
j-rivero authored Nov 4, 2024
1 parent 46cdd91 commit c41059a
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 55 deletions.
6 changes: 2 additions & 4 deletions jenkins-scripts/docker/debian-ratt-builder.bash
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ echo '# BEGIN SECTION: setup the testing enviroment'
# Define the name to be used in docker
export DOCKER_JOB_NAME="debian_ratt_builder"
. "${SCRIPT_DIR}/lib/boilerplate_prepare.sh"
. "${SCRIPT_DIR}/lib/_common_scripts.bash"
echo '# END SECTION'

cat > build.sh << DELIM
###################################################
# Make project-specific changes here
#
set -ex
$(generate_buildsh_header)
if ${USE_UNSTABLE}; then
TARGET_DISTRO='unstable'
Expand Down
4 changes: 2 additions & 2 deletions jenkins-scripts/docker/gz-source-generation.bash
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ echo '# BEGIN SECTION: setup the testing enviroment'
# Define the name to be used in docker
export DOCKER_JOB_NAME="source_generation_job"
. ${SCRIPT_DIR}/lib/boilerplate_prepare.sh
. ${SCRIPT_DIR}/lib/_common_scripts.bash
echo '# END SECTION'

cat > build.sh << DELIM
#!/bin/bash
set -ex
$(generate_buildsh_header)
PKG_DIR=\$WORKSPACE/pkgs
SOURCES_DIR=\$WORKSPACE/sources
Expand Down
13 changes: 13 additions & 0 deletions jenkins-scripts/docker/lib/_common_scripts.bash
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
export APT_INSTALL="sudo DEBIAN_FRONTEND=noninteractive apt-get install -y"

generate_buildsh_header()
{
SHELL_ON_ERRORS=${SHELL_ON_ERRORS:-false}
echo "#!/bin/bash"
echo "set -ex"
if ${SHELL_ON_ERRORS}; then
echo 'trap "/bin/bash" 0 INT QUIT ABRT PIPE TERM'
fi
if $GENERIC_ENABLE_TIMING; then
echo "source ${TIMING_DIR}/_time_lib.sh ${WORKSPACE}"
fi
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@ fi
[[ -z $GENERIC_ENABLE_CPPCHECK ]] && GENERIC_ENABLE_CPPCHECK=true
[[ -z $GENERIC_ENABLE_TESTS ]] && GENERIC_ENABLE_TESTS=true

cat > build.sh << DELIM_HEADER
#!/bin/bash
set -ex
. ${SCRIPT_DIR}/lib/_common_scripts.bash

if $GENERIC_ENABLE_TIMING; then
source ${TIMING_DIR}/_time_lib.sh ${WORKSPACE}
fi
cat > build.sh << DELIM_HEADER
$(generate_buildsh_header)
DELIM_HEADER

# Process the source build of dependencies if needed
Expand Down
4 changes: 4 additions & 0 deletions jenkins-scripts/docker/lib/boilerplate_prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ source ${SCRIPT_DIR}/../lib/boilerplate_timing_prepare.sh
init_stopwatch TOTAL_TIME
init_stopwatch CREATE_TESTING_ENVIROMENT

# Enable shell on errors is designed to help debuging but never
# to be run on Jenkins.
SHELL_ON_ERRORS=${SHELL_ON_ERRORS:-false}

# Default values - Provide them is prefered
if [ -z ${DISTRO} ]; then
DISTRO=bionic
Expand Down
7 changes: 2 additions & 5 deletions jenkins-scripts/docker/lib/debbuild-backport.bash
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@ fi
export ENABLE_REAPER=false

. ${SCRIPT_DIR}/lib/boilerplate_prepare.sh
. ${SCRIPT_DIR}/lib/_common_scripts.bash

cat > build.sh << DELIM
###################################################
# Make project-specific changes here
#
#!/usr/bin/env bash
set -ex
$(generate_buildsh_header)
cd $WORKSPACE/build
Expand Down
7 changes: 2 additions & 5 deletions jenkins-scripts/docker/lib/debbuild-base.bash
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@ fi
export ENABLE_REAPER=false

. ${SCRIPT_DIR}/lib/boilerplate_prepare.sh
. ${SCRIPT_DIR}/lib/_common_scripts.bash
. ${SCRIPT_DIR}/lib/_gazebo_utils.sh

cat > build.sh << DELIM
###################################################
# Make project-specific changes here
#
#!/usr/bin/env bash
set -ex
$(generate_buildsh_header)
cd $WORKSPACE/build
Expand Down
7 changes: 2 additions & 5 deletions jenkins-scripts/docker/lib/debbuild-bloom-base.bash
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@ export ENABLE_REAPER=false
PACKAGE_UNDERSCORE_NAME=${PACKAGE//-/_}

. ${SCRIPT_DIR}/lib/boilerplate_prepare.sh
. ${SCRIPT_DIR}/lib/_common_scripts.bash
. ${SCRIPT_DIR}/lib/_gazebo_utils.sh

cat > build.sh << DELIM
###################################################
# Make project-specific changes here
#
#!/usr/bin/env bash
set -ex
$(generate_buildsh_header)
cd $WORKSPACE/build
Expand Down
7 changes: 2 additions & 5 deletions jenkins-scripts/docker/lib/debian-git-repo-base.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
export ENABLE_REAPER=false

. ${SCRIPT_DIR}/lib/boilerplate_prepare.sh
. ${SCRIPT_DIR}/lib/_common_scripts.bash
. ${SCRIPT_DIR}/lib/_gazebo_utils.sh

# The git plugin leaves a repository copy with a detached HEAD
Expand All @@ -26,11 +27,7 @@ if [[ -z ${BRANCH} ]]; then
fi

cat > build.sh << DELIM
###################################################
# Make project-specific changes here
#
#!/usr/bin/env bash
set -ex
$(generate_buildsh_header)
if ${CLONE_NEEDED}; then
echo '# BEGIN SECTION: clone the git repo'
Expand Down
5 changes: 4 additions & 1 deletion jenkins-scripts/docker/lib/docker_generate_dockerfile.bash
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,12 @@ if [[ -z ${OSRF_REPOS_TO_USE} ]]; then
fi
fi

# Enable shell on errors is designed to help debuging but never
# to be run on Jenkins.
SHELL_ON_ERRORS=${SHELL_ON_ERRORS:-false}

echo '# BEGIN SECTION: create the Dockerfile'
cat > Dockerfile << DELIM_DOCKER
#!/bin/bash
#######################################################
# Docker file to run build.sh
Expand Down
9 changes: 4 additions & 5 deletions jenkins-scripts/docker/lib/gazebo_ros_pkgs-check-release.bash
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export ENABLE_REAPER=false

DOCKER_JOB_NAME="gazebo_ros_pkgs_ci"
. ${SCRIPT_DIR}/lib/boilerplate_prepare.sh
. ${SCRIPT_DIR}/lib/_common_scripts.bash
. ${SCRIPT_DIR}/lib/_gazebo_utils.sh

ROS_SETUP_PREINSTALL_HOOK="""
Expand All @@ -20,7 +21,8 @@ ${GAZEBO_MODEL_INSTALLATION}

if ${ROS2}; then
cat > build.sh << DELIM_CHECKOUT
set -ex
$(generate_buildsh_header)
source /opt/ros/${ROS_DISTRO}/setup.bash
TEST_TIMEOUT=90
Expand All @@ -36,10 +38,7 @@ fi
DELIM_CHECKOUT
else
cat > build.sh << DELIM_CHECKOUT
###################################################
# Make project-specific changes here
#
set -ex
$(generate_buildsh_header)
[[ -d ${WORKSPACE}/gazebo_ros_demos ]] && rm -fr ${WORKSPACE}/gazebo_ros_demos
git clone https://github.com/ros-simulation/gazebo_ros_demos ${WORKSPACE}/gazebo_ros_demos
Expand Down
8 changes: 2 additions & 6 deletions jenkins-scripts/docker/lib/generic-abi-base.bash
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ echo '# BEGIN SECTION: setup the testing enviroment'
# Define the name to be used in docker
DOCKER_JOB_NAME="abi_job"
. ${SCRIPT_DIR}/lib/boilerplate_prepare.sh
. ${SCRIPT_DIR}/lib/_common_scripts.bash
echo '# END SECTION'

# Could be empty, just fine
Expand All @@ -44,12 +45,7 @@ if [[ "${NEED_C17_COMPILER}" == "true" ]]; then
fi

cat > build.sh << DELIM
#!/bin/bash
###################################################
# Make project-specific changes here
#
set -ex
$(generate_buildsh_header)
if [ `expr length "${ABI_JOB_PRECHECKER_HOOK} "` -gt 1 ]; then
echo '# BEGIN SECTION: running pre ABI hook'
Expand Down
7 changes: 1 addition & 6 deletions jenkins-scripts/docker/lib/generic-install-base.bash
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ DOCKER_JOB_NAME="install_job"
echo '# END SECTION'

cat > build.sh << DELIM
#!/bin/bash
###################################################
# Make project-specific changes here
#
set -ex
$(generate_buildsh_header)
if [ `expr length "${INSTALL_JOB_PREINSTALL_HOOK} "` -gt 1 ]; then
echo '# BEGIN SECTION: running pre install hook'
Expand Down
8 changes: 3 additions & 5 deletions jenkins-scripts/docker/lib/gzdev-base-linux.bash
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
echo '# BEGIN SECTION: setup the testing enviroment'
export DOCKER_JOB_NAME="gzdev"
. "${SCRIPT_DIR}/lib/boilerplate_prepare.sh"
. "${SCRIPT_DIR}/lib/_common_scripts.bash"
. "${SCRIPT_DIR}/lib/_install_nvidia_docker.sh"
echo '# END SECTION'

. ${SCRIPT_DIR}/lib/_install_nvidia_docker.sh

cat > build.sh << DELIM
###################################################
#
set -ex
$(generate_buildsh_header)
export MAKE_JOBS=${MAKE_JOBS}
export DISPLAY=${DISPLAY}
Expand Down

0 comments on commit c41059a

Please sign in to comment.