#!/usr/bin/env bash # vim:ts=4:sts=4:sw=4:et # # Author: Hari Sekhon # Date: 2020-03-28 15:16:18 +0000 (Sat, 28 Mar 2020) # # https://github.com/harisekhon/bash-tools # # License: see accompanying Hari Sekhon LICENSE file # # If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish # # https://www.linkedin.com/in/harisekhon # set -euo pipefail [ -n "${DEBUG:-}" ] && set -x srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" config="$srcdir/setup/jenkins-docker-compose.yml" if [ -z "${JENKINS_PASSWORD:-}" ]; then JENKINS_PASSWORD="$(docker-compose -f "$config" exec jenkins-server cat /var/jenkins_home/secrets/initialAdminPassword)" fi # if sourced, export JENKINS_PASSWORD, if subshell, echo it if [[ "$_" != "$0" ]]; then export JENKINS_PASSWORD else echo "$JENKINS_PASSWORD" fi