Configuring the CI/CD pipeline with Bash
In this section, we’ll cover Bash scripting for setting up our CI/CD test lab environment. This will automate the installation of all tools needed for the rest of the chapter exercises. This script can be found in GitHub as ch16_setup_environment.sh
.
Initial setup and error handling
This section of the code sets up error-handling behaviors that prevent the script from continuing when errors occur. These safety measures help catch problems early and prevent cascading failures that could leave the system in an inconsistent state. As usual, the code starts with the familiar shebang line:
#!/usr/bin/env bash set -euo pipefail IFS=$'\n\t' # Setup logging LOG_FILE="/var/log/devsecops_setup.log" SCRIPT_NAME=$(basename "$0")
This section establishes core script behaviors. The set
command configures important safety features:
-e
: Exits on any error-u
: Treats unset variables as errors-o...