diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b3d5bb250c26e31300239f104e70f17d14bc39ca..b91a8b2b04e2d0b957e2f8b8ba16dc6504eb247a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -53,6 +53,7 @@ version: allow_failure: true variables: CHART_FILE: chart/Chart.yaml + BASEGIT_FILE: base/gitrepository.yaml script: - git fetch --all - ./scripts/lint_version.sh diff --git a/scripts/lint_version.sh b/scripts/lint_version.sh index 81aa0476cb23c1fe70fc8d360b7c2f9ae1bfc0ba..34c63c39be1a95555c87e1b433c11dd158b37baf 100755 --- a/scripts/lint_version.sh +++ b/scripts/lint_version.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash -# obtain the default version -default_version=$(git show origin/${CI_DEFAULT_BRANCH}:${CHART_FILE} | grep -oP 'version: \K(.*)') +# obtain the default chart version +chart_default_version=$(git show origin/${CI_DEFAULT_BRANCH}:${CHART_FILE} | ggrep -oP 'version: \K(.*)') # check for command error if [ $? -ne 0 ]; then @@ -9,8 +9,8 @@ if [ $? -ne 0 ]; then exit 1 fi -# obtain the local version -local_version=$(cat ${CHART_FILE} | grep -oP 'version: \K(.*)') +# obtain the local chart version +chart_local_version=$(cat ${CHART_FILE} | ggrep -oP 'version: \K(.*)') # check for command error if [ $? -ne 0 ]; then @@ -18,15 +18,47 @@ if [ $? -ne 0 ]; then exit 1 fi +# obtain the default base git repository tag +basegit_default_tag=$(git show origin/${CI_DEFAULT_BRANCH}:${BASEGIT_FILE} | ggrep -oP 'tag: \K(.*)') + +# check for command error +if [ $? -ne 0 ]; then + echo "Error: An unknown error has occurred while attempting to retrieve the default tag from ${BASEGIT_FILE}" + exit 1 +fi + +# obtain the local base git repository tag +basegit_local_tag=$(cat ${BASEGIT_FILE} | ggrep -oP 'tag: \K(.*)') + +# check for command error +if [ $? -ne 0 ]; then + echo "Error: An unknown error has occurred while attempting to retrieve the local tag from ${BASEGIT_FILE}" + exit 1 +fi + # debug print -echo "Default version: $default_version" -echo "Local version: $local_version" +echo "Default chart version: $chart_default_version" +echo "Local chart version: $chart_local_version" + +# assume success +exit_code=0 # error if the versions are not different -if [[ "$default_version" == "$local_version" ]]; then +if [[ "$chart_default_version" == "$chart_local_version" ]]; then echo "The version has not been updated in ${CHART_FILE}, please update this file" - exit 1 + exit_code=1 +fi + +echo "--" + +echo "Default base git repository version: $basegit_default_tag" +echo "Local base git repository version: $basegit_local_tag" + +# error if the versions are not different +if [[ "$chart_default_version" == "$chart_local_version" ]]; then + echo "The tag has not been updated in ${CHART_FILE}, please update this file" + exit_code=1 fi -# default to success -exit 0 \ No newline at end of file +# exit with stored code +exit $exit_code \ No newline at end of file