mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-20 23:05:49 +00:00
20240620_162302
This commit is contained in:
parent
48ecb1d4aa
commit
d9a4724a3d
8 changed files with 82 additions and 8 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -15,3 +15,4 @@ build/*
|
||||||
_site/
|
_site/
|
||||||
*.css
|
*.css
|
||||||
!petclinic.css
|
!petclinic.css
|
||||||
|
scr_local_secrets.sh
|
||||||
|
|
|
@ -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
|
||||||
|
|
11
scr__test__local_scripts.sh
Normal file
11
scr__test__local_scripts.sh
Normal 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)"
|
9
scr_local_secrets_example.sh
Normal file
9
scr_local_secrets_example.sh
Normal 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)"
|
||||||
|
|
|
@ -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}"
|
||||||
|
|
|
@ -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=(
|
||||||
|
|
53
scr_validate_mandatory_variables.sh
Normal file
53
scr_validate_mandatory_variables.sh
Normal 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)"
|
||||||
|
|
Loading…
Reference in a new issue