20240620_162302

This commit is contained in:
Barry Matheney 2024-06-20 16:23:02 -04:00
parent 48ecb1d4aa
commit d9a4724a3d
8 changed files with 82 additions and 8 deletions

1
.gitignore vendored
View file

@ -15,3 +15,4 @@ build/*
_site/ _site/
*.css *.css
!petclinic.css !petclinic.css
scr_local_secrets.sh

View file

@ -13,12 +13,16 @@ pipelines:
caches: caches:
- docker - docker
script: script:
- ps -p $$ && echo whoami - ps -p $$ && whoami
- cat /etc/os-release - cat /etc/os-release
- echo "$SHELL" - echo "$SHELL"
- source scr_scrub_bitbucket_env_vars.sh - source scr_scrub_bitbucket_env_vars.sh
- source scr_non_secret_env_vars.sh - source scr_non_secret_env_vars.sh
- printenv | sort - printenv | sort
- source scr_validate_mandatory_variables.sh
- echo "$HARBOR_ACCESS_TOKEN" | docker login "$HARBOR_LOGIN_ADDRESS" -u "$HARBOR_USERNAME" --password-stdin
- docker build -t "${DOCKER_IMAGE_NAME}:${DOCKER_TAG_PIPELINE_UUID}" .
- docker push "${DOCKER_IMAGE_NAME}:${DOCKER_TAG_PIPELINE_UUID}"
# - docker build - # - docker build -
# - source pack_install.sh # - source pack_install.sh
# - which pack && pack version # - which pack && pack version

View file

@ -0,0 +1,11 @@
#!/usr/bin/env bash
echo "$(date +%Y%m%d_%H%M%S) Entering $(basename "$(realpath "${BASH_SOURCE[0]}")") on host $(hostname)"
source scr__test__pipeline_variables.sh
source scr_local_secrets.sh
source scr_scrub_bitbucket_env_vars.sh
source scr_non_secret_env_vars.sh
source scr_validate_mandatory_variables.sh
echo "$(date +%Y%m%d_%H%M%S) Leaving $(basename "$(realpath "${BASH_SOURCE[0]}")") on host $(hostname)"

View file

@ -0,0 +1,9 @@
#!/usr/bin/env bash
echo "$(date +%Y%m%d_%H%M%S) - Entering $(basename "$(realpath "${BASH_SOURCE[0]}")") on host $(hostname)"
export HARBOR_USERNAME="barry_matheney@yahoo.com"
export HARBOR_LOGIN_ADDRESS="c8n.io/barrymatheney"
export HARBOR_ACCESS_TOKEN="whatever the access token that you created is"
echo "$(date +%Y%m%d_%H%M%S) - Leaving $(basename "$(realpath "${BASH_SOURCE[0]}")") on host $(hostname)"

View file

@ -1,8 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
echo "$(date +%Y%m%d_%H%M%S) - Entering $(basename "$(realpath "${BASH_SOURCE[0]}")") on host $(hostname)" echo "$(date +%Y%m%d_%H%M%S) - Entering $(basename "$(realpath "${BASH_SOURCE[0]}")") on host $(hostname)"
export DOCKER_IMAGE_NAME="${BITBUCKET_REPO_FULL_NAME_SCRUBBED}" export DOCKER_IMAGE_NAME="${HARBOR_LOGIN_ADDRESS}/${BITBUCKET_REPO_FULL_NAME_SCRUBBED}"
export DOCKER_TAG_COMMIT_SHA="${BITBUCKET_COMMIT_SCRUBBED}" export DOCKER_TAG_PIPELINE_UUID="${BITBUCKET_PIPELINE_UUID_SCRUBBED}"
export DOCKER_TAG_COMMIT_SHA="${BITBUCKET_COMMIT_SCRUBBED}" export DOCKER_TAG_COMMIT_SHA="${BITBUCKET_COMMIT_SCRUBBED}"
export DOCKER_TAG_BRANCH_NAME="${BITBUCKET_BRANCH_SCRUBBED}" export DOCKER_TAG_BRANCH_NAME="${BITBUCKET_BRANCH_SCRUBBED}"
export DOCKER_TAG_BRANCH_NAME="${BITBUCKET_PIPELINE_UUID_SCRUBBED}" export DOCKER_TAG_BRANCH_NAME="${BITBUCKET_PIPELINE_UUID_SCRUBBED}"

View file

@ -1,11 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
echo "$(date +%Y%m%d_%H%M%S) - Entering $(basename "$(realpath "${BASH_SOURCE[0]}")") on host $(hostname)" echo "$(date +%Y%m%d_%H%M%S) - Entering $(basename "$(realpath "${BASH_SOURCE[0]}")") on host $(hostname)"
if [ -z ${BITBUCKET_BRANCH+x} ]; then # this shouldn't be defined locally, so we can use it to determine local vs pipeline run and tests...
source scr_test_pipeline_variables.sh
else
echo "Running in a pipeline, using Bitbuckets real variable values."
fi
# List of characters to replace # List of characters to replace
declare -A char_replacements=( declare -A char_replacements=(

View file

@ -0,0 +1,53 @@
#!/usr/bin/env bash
echo "$(date +%Y%m%d_%H%M%S) - Entering $(basename "$(realpath "${BASH_SOURCE[0]}")") on host $(hostname)"
# Function to check if a variable is defined
check_variable_defined() {
local var_name=$1
if [ -z "${!var_name}" ]; then
echo "$var_name"
fi
}
# List of necessary variables to check
necessary_variables=(
"DOCKER_IMAGE_NAME"
"HARBOR_LOGIN_ADDRESS"
"BITBUCKET_REPO_FULL_NAME_SCRUBBED"
"DOCKER_TAG_PIPELINE_UUID"
"BITBUCKET_PIPELINE_UUID_SCRUBBED"
"DOCKER_TAG_COMMIT_SHA"
"BITBUCKET_COMMIT_SCRUBBED"
"DOCKER_TAG_BRANCH_NAME"
"BITBUCKET_BRANCH_SCRUBBED"
"DOCKER_TAG_BRANCH_NAME"
"BITBUCKET_PIPELINE_UUID_SCRUBBED"
"HARBOR_ACCESS_TOKEN"
"HARBOR_USERNAME"
)
# Array to store undefined variables
undefined_variables=()
# Iterate through the list of necessary variables and check if they are defined
for var in "${necessary_variables[@]}"; do
result=$(check_variable_defined "$var")
if [ -n "$result" ]; then
undefined_variables+=("$result")
fi
done
# Print out which variables are not defined
if [ ${#undefined_variables[@]} -ne 0 ]; then
echo "The following variables are not defined:"
for var in "${undefined_variables[@]}"; do
echo "$var"
done
else
echo "MSG: All necessary variables are defined, should be good to go."
fi
echo "$(date +%Y%m%d_%H%M%S) - Leaving $(basename "$(realpath "${BASH_SOURCE[0]}")") on host $(hostname)"