Skip to content

Enhance Helm Package Script to Allow Custom version_label on Non-Prod Branches

Description

The current helm package script automatically appends the branch slug to the version_label for non-production branches without allowing for user customization. This behavior might not align with all project versioning strategies, particularly in environments where a specific versioning scheme is required for integration or compliance reasons.

Implementation ideas

Proposed Solution

Introduce an enhancement to the script to check for a user-defined version_label variable. If this variable is not set, the script should default to using the branch slug as the version_label. This modification will offer greater flexibility in version naming conventions, catering to diverse project needs.

Suggested Implementation

in the function function helm_package()

#if on non-prod branch: also append branch slug as version label if [[ -z "${CI_COMMIT_TAG}" ]]; then prod_ref_expr=${PROD_REF#/} prod_ref_expr=${prod_ref_expr%/} if [[ ! "$CI_COMMIT_REF_NAME" =~ $prod_ref_expr ]]; then # Check if a custom version_label is defined if [[ -z "${CUSTOM_VERSION_LABEL}" ]]; then version_label="-$CI_COMMIT_REF_SLUG" else version_label="${CUSTOM_VERSION_LABEL}" fi log_info "[info] Using version label: \\e[33;1m${version_label}\\e[0m" fi fi