diff --git a/.ci/pipelines/openshift-ci-tests.sh b/.ci/pipelines/openshift-ci-tests.sh index a2401412ac..c5cf8d25d8 100755 --- a/.ci/pipelines/openshift-ci-tests.sh +++ b/.ci/pipelines/openshift-ci-tests.sh @@ -55,7 +55,23 @@ main() { log::info "Log file: ${LOGFILE}" log::info "JOB_NAME : $JOB_NAME" - CHART_VERSION=$(get_chart_version "$CHART_MAJOR_VERSION") + if [[ -n "${CHART_VERSION:-}" ]]; then + log::info "Using preset CHART_VERSION (pinned or from env): ${CHART_VERSION}" + elif [[ "${TAG_NAME:-}" =~ ^[0-9]+\.[0-9]+-[0-9]+$ ]]; then + # The image and the chart are published together under the same build + # number, so a pinned TAG_NAME already determines the chart. Resolving the + # newest chart here instead would pair a pinned RC image with a chart from + # a later build. + CHART_VERSION="${TAG_NAME}-CI" + log::info "Derived CHART_VERSION from pinned TAG_NAME: ${CHART_VERSION}" + elif [[ "${TAG_NAME:-}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + # A GA verification pins the image to x.y.z and passes no --chart-version. + # The chart repo publishes the same x.y.z tag, so map it straight across. + CHART_VERSION="${TAG_NAME}" + log::info "Derived CHART_VERSION from pinned GA TAG_NAME: ${CHART_VERSION}" + else + CHART_VERSION=$(get_chart_version "$CHART_MAJOR_VERSION") + fi export CHART_VERSION case "$JOB_NAME" in diff --git a/.ci/pipelines/utils.sh b/.ci/pipelines/utils.sh index aad778104c..d87342c48a 100755 --- a/.ci/pipelines/utils.sh +++ b/.ci/pipelines/utils.sh @@ -1510,7 +1510,7 @@ get_previous_release_version() { get_chart_version() { local chart_major_version=$1 curl -sSX GET "https://quay.io/api/v1/repository/rhdh/chart/tag/?onlyActiveTags=true&filter_tag_name=like:${chart_major_version}-" -H "Content-Type: application/json" \ - | jq '.tags[0].name' | grep -oE '[0-9]+\.[0-9]+-[0-9]+-CI' + | jq -r '[.tags[] | select(.name | test("^[0-9]+\\.[0-9]+-[0-9]+-CI$"))] | max_by(.start_ts) | .name // empty' } # Helper function to get dynamic value file path based on previous release version