Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
292c62f
test
Axuba Dec 10, 2024
e9d2701
test
Axuba Dec 10, 2024
42353bd
test
Axuba Dec 11, 2024
269cb46
test
Axuba Dec 11, 2024
8dfa4b7
test
Axuba Dec 11, 2024
5598a01
test
Axuba Dec 11, 2024
ecb1b83
test
Axuba Dec 12, 2024
cf257c4
tesT
Axuba Dec 12, 2024
7e9c205
test
Axuba Dec 13, 2024
873012a
test
Axuba Dec 13, 2024
0a5b6b9
test
Axuba Dec 16, 2024
b0e8fb5
test
Axuba Dec 19, 2024
c090765
test
Axuba Dec 19, 2024
f3100b1
test
Axuba Dec 19, 2024
8622961
test
Axuba Dec 19, 2024
0ed659c
test
Axuba Dec 19, 2024
a7abbbf
Add snapshot id parameter to be also exported
Axuba Dec 31, 2024
9e83286
test
Axuba Jan 15, 2025
0fe16e4
test
Axuba Jan 16, 2025
8d3c9a0
Update fbc-post-release.yaml
Axuba Jan 20, 2025
67909fd
Add version and releasePlan null params
Axuba Jan 30, 2025
4b00938
Update script
Axuba Jan 30, 2025
d0c8e35
Temporarily hardcode version parameter
Axuba Jan 30, 2025
6727160
Change stages to lanes folder
Axuba Jan 30, 2025
990246e
Channel folder to commit to will now depend on the fbc channel itself
Axuba Jan 31, 2025
4dbebd1
Update fbc-post-release.yaml
Axuba Feb 6, 2025
e12796d
added prNumber to the payload structure
tal-hason Feb 20, 2025
7db7353
Merge pull request #2 from openshift-cnv/adde-PRnumber-to-payload-schema
Axuba Feb 24, 2025
e1eed21
added minorVersion for kargo to use
tal-hason Mar 2, 2025
81eefca
Merge pull request #3 from openshift-cnv/minor-version-key
Axuba Mar 3, 2025
a3935a6
first release
tal-hason Mar 18, 2025
b326d2b
Merge pull request #4 from openshift-cnv/firstRelease-Flag
Axuba Mar 18, 2025
215bea2
Separate v4.99 builds on fbc payloads
Axuba Mar 28, 2025
4d9db25
Add version, releaseplan and freightname data
Axuba Jun 4, 2025
f50ff82
Merge pull request #5 from openshift-cnv/Axuba-patch-1
Axuba Jun 6, 2025
7c2fc9f
Temporarily update repo
Axuba Jun 6, 2025
0b36a55
Fix
Axuba Jun 6, 2025
d1e07c4
Update fbc-post-release.yaml
Axuba Jun 6, 2025
c29b04d
Update fbc-post-release.yaml
tal-hason Jul 2, 2025
e4296d5
Add rhelVersion parameter
Axuba Jul 15, 2025
1ed5ae7
Add environment parameter
Axuba Aug 25, 2025
cc4c615
Fix typo
Axuba Aug 25, 2025
2e64cc5
Add update-bundle pipeline (#8)
Axuba Nov 26, 2025
3e36af3
Pull with creds
Axuba Nov 26, 2025
d12c626
Make sure all the commits in every component are the same
Axuba Nov 27, 2025
53553ee
Fix IIB status path as it changed
Axuba Nov 27, 2025
2297da5
Fix operator check as now it includes -rhel suffix
Axuba Dec 10, 2025
545e7e3
Another fix so test images dont go to core params
Axuba Dec 10, 2025
7847dd7
Add snapshot id to a new snapshots json file
Axuba Dec 22, 2025
bc659e8
Push release skeleton for hco-bundle-images (#9)
Axuba Jan 8, 2026
ac16481
Use tmp for quay build creds path
Axuba Jan 8, 2026
adb0e6e
Use pipeline tools image to push the chart
Axuba Jan 8, 2026
38c121b
Check if there are actually changes before committing
Axuba Jan 8, 2026
b4e410c
Increase clone depth
Axuba Jan 8, 2026
8003543
Work under a tmpdir
Axuba Jan 8, 2026
ce791e2
Use tmp as home, instead of default /
Axuba Jan 8, 2026
28d5b62
Fix quay url
Axuba Jan 8, 2026
7f6c73a
Fill releaseplan and namespace
Axuba Jan 8, 2026
0b30634
Fix
Axuba Jan 8, 2026
05da569
Fix typo
Axuba Jan 8, 2026
98e6950
Add hco bundle url to payload
Axuba Jan 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 130 additions & 0 deletions fbc/fbc-post-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
---
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: fbc-post-release
spec:
description: This tasks gets all the required data of an FBC build and commits it to a payload repository to be used in a GitOps environment.
params:
- name: snapshot
type: string
- name: cnv_version
type: string
- name: releaseplan_id
type: string
- name: environment
type: string
tasks:
- name: get-info
params:
- name: SNAPSHOT
value: "$(params.snapshot)"
- name: CNV_VERSION
value: "$(params.cnv_version)"
- name: RELEASEPLAN_ID
value: "$(params.releaseplan_id)"
- name: ENVIRONMENT
value: "$(params.environment)"
taskSpec:
params:
- name: SNAPSHOT
type: string
- name: CNV_VERSION
type: string
- name: RELEASEPLAN_ID
type: string
- name: ENVIRONMENT
type: string
steps:
- name: get-info
image: quay.io/konflux-ci/release-service-utils:0a58b6a6b562879e89395636d97931f2dcbb494c
envFrom:
- secretRef:
name: cnv-ci-release-token
script: |
#!/usr/bin/env bash
set -eo pipefail

snapshot_id=$(echo "$(params.SNAPSHOT)" | awk -F'/' '{print $2}')
release_id=$(kubectl get release --sort-by=.metadata.creationTimestamp -o json | \
jq -r --arg snapshot "${snapshot_id}" --arg releaseplan "$(params.RELEASEPLAN_ID)" \
'.items[] | select(.spec.snapshot == $snapshot and .spec.releasePlan == $releaseplan) | .metadata.name' | tail -n 1)

released_status=$(kubectl get release "${release_id}" -oyaml | yq '.status.conditions[] | select(.type == "ManagedPipelineProcessed") | .status')
if [ "$released_status" != "True" ]; then
echo "Release failed. Not continuing with post-release."
exit 1
fi

cnv_version="$(params.CNV_VERSION)"
snapshot_data=$(kubectl get snapshot "${snapshot_id}" -oyaml)
fbc_fragment=$(echo "${snapshot_data}" | yq '.spec.components[0].containerImage')
index_image=$(kubectl get release "${release_id}" -oyaml | yq ".status.artifacts.index_image.\"${cnv_version}\".index_image")
from_index="registry-proxy.engineering.redhat.com/rh-osbs/iib-pub-pending:${cnv_version}"

git_commit=$(echo "${snapshot_data}" | yq '.spec.components[0].source.git.revision')
git_repo=$(echo "${snapshot_data}" | yq '.spec.components[0].source.git.url')
gitfbcdir=$(mktemp -d) && cd "${gitfbcdir}"
git init
git remote add origin "${git_repo}.git"
git fetch origin "${git_commit}" --depth 1
git checkout "${git_commit}"
image_sha=$(yq '.image' ${cnv_version}/updated_image.yaml)
channel=$(yq '.channel' ${cnv_version}/updated_image.yaml)
hco_bundle_version=$(yq '.hco-bundle-version' ${cnv_version}/updated_image.yaml)
hco_bundle_url=$(yq '.hco-bundle-url' ${cnv_version}/updated_image.yaml)

if [[ $hco_bundle_version == v4.99* ]]; then
cnv_version="v4.99"
fi

gitpayloaddir=$(mktemp -d) && cd "${gitpayloaddir}"
git clone https://${github_token}@github.com/openshift-cnv/cnv-fbc-payloads-new.git && cd cnv-fbc-payloads-new
git config --global user.name "${github_username}"
git config --global user.email "[email protected]"

case $(params.ENVIRONMENT) in
"production")
NEXT_STAGE="verify-production-release"
;;
"stage")
NEXT_STAGE="stage"
;;
*)
echo "Unknown environment: $(params.ENVIRONMENT)"
exit 1
;;
esac
save_folder="${cnv_version//./-}/lanes/${channel}/${NEXT_STAGE}"
mkdir -p "${save_folder}"
echo "" > "${save_folder}/payload.yaml"
yq e ".index_image = \"${index_image}\"" -i ${save_folder}/payload.yaml
yq e ".snapshot_id = \"${snapshot_id}\"" -i ${save_folder}/payload.yaml
yq e ".from_index = \"${from_index}\"" -i ${save_folder}/payload.yaml
yq e ".fbc_fragment = \"${fbc_fragment}\"" -i ${save_folder}/payload.yaml
yq e ".channel = \"${channel}\"" -i ${save_folder}/payload.yaml
yq e ".hco_bundle_registry_by_sha = \"${image_sha}\"" -i ${save_folder}/payload.yaml
image_base=$(echo "${image_sha}" | cut -d'@' -f1)
yq e ".hco_bundle_registry_by_tag = \"${image_base}:${hco_bundle_version}\"" -i ${save_folder}/payload.yaml
yq e ".hco_bundle_version = \"${hco_bundle_version}\"" -i ${save_folder}/payload.yaml
yq e ".hco_bundle_url = \"${hco_bundle_url}\"" -i ${save_folder}/payload.yaml
# Add the minor version number from the bundle for Kargo
yq e '.minorVersion = (.hco_bundle_version | split("-") | .[0])' -i ${save_folder}/payload.yaml
yq e '.rhelVersion = (.minorVersion | split(".") | .[3])' -i ${save_folder}/payload.yaml
yq e ".version = \"${cnv_version//./-}\"" -i ${save_folder}/payload.yaml
yq e ".releasePlan = \"${NEXT_STAGE}\"" -i ${save_folder}/payload.yaml
yq e ".freightName = \"${snapshot_id}\"" -i ${save_folder}/payload.yaml
yq e ".freightID = null" -i ${save_folder}/payload.yaml
yq e ".prNumber = null" -i ${save_folder}/payload.yaml
# add a firstRelease flag to the payload
patch_version=$(echo "$hco_bundle_version" | grep -oP 'v\d+\.\d+\.\K\d+')
if [ "$patch_version" -eq 0 ]; then
yq -i '.firstRelease = true' ${save_folder}/payload.yaml
else
yq -i '.firstRelease = false' ${save_folder}/payload.yaml
fi


git add .
git commit -m "Update payload $hco_bundle_version"
git push origin main
163 changes: 163 additions & 0 deletions pipelines/update-bundle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
---
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: update-bundle
spec:
description: This tasks gets all the required data of an FBC build and commits it to a payload repository to be used in a GitOps environment.
params:
- name: snapshot
type: string
tasks:
- name: update-bundle
params:
- name: SNAPSHOT
value: "$(params.snapshot)"
taskSpec:
params:
- name: SNAPSHOT
type: string
results:
- name: snapshots-to-release
description: Contents of the snapshots.json file
- name: bundle-version
description: NVR of the bundle
volumes:
- name: quay-creds
secret:
secretName: quay-builds-creds
steps:
- name: update-bundle
image: quay.io/konflux-ci/release-service-utils@sha256:2f9e6863e82bbc9ddce5a290f3fd0e87657c475e3de8a832b2ef7f8d0671e7d3
envFrom:
- secretRef:
name: hco-updater-gitlab-token
script: |
#!/usr/bin/env bash
set -eo pipefail

SNAPSHOT_ID=$(echo "$(params.SNAPSHOT)" | awk -F'/' '{print $2}')
SNAPSHOT_DATA=$(kubectl get snapshot $SNAPSHOT_ID -ojson)
NAMESPACE=$(jq -r '.metadata.namespace' <<< "$SNAPSHOT_DATA")
APPLICATION=$(jq -r '.spec.application' <<< "$SNAPSHOT_DATA")
VERSION=$(echo "$NAMESPACE" | cut -d'-' -f1,2)
REPO_URL="https://gitlab.cee.redhat.com/openshift-virtualization/konflux-builds/${VERSION}/hco-bundle-registry.git"
REPO_URL=$(echo "$REPO_URL" | sed "s|https://|https://oauth2:${GITLAB_TOKEN}@|")

git clone $REPO_URL --depth 50
cd hco-bundle-registry
git remote set-url origin "$REPO_URL"
git config user.name "submodule-sync"
git config user.email "[email protected]"

IMAGES=$(jq -r '.spec.components[].containerImage' <<< "$SNAPSHOT_DATA")

# Make sure all the commits in every component are the same
if jq -e '[.spec.components[].source.git.revision] | unique | length == 1' <<< "$SNAPSHOT_DATA" > /dev/null; then
echo "The snapshot has all the components pointing to the same commit, continuing."
else
echo "Commits are inconsistent!"
exit 1
fi

function update_images_snapshots() {
for img in $IMAGES; do
image_name_sha=$(echo "${img##*/}")
image_name=$(echo "$image_name_sha" | cut -d'@' -f1)

if [[ "$image_name" == *"-operator-rhel"* ]]; then
json_file="components/hco-bundle-registry/core-params.json"
else
json_file="components/hco-bundle-registry/extra-params.json"
fi
jq ".\"${image_name}-image\" = \"${image_name_sha}\"" "$json_file" > "${json_file}.tmp" && mv "${json_file}.tmp" "$json_file"
done

snapshots_file="components/hco-bundle-registry/snapshots.json"
touch ${snapshots_file}
jq -n \
--slurpfile f "$snapshots_file" \
--arg app "$APPLICATION" \
--arg snap "$SNAPSHOT_ID" \
'$f[0] // {} | .[$app] = $snap' \
> "$snapshots_file.tmp" \
&& mv "$snapshots_file.tmp" "$snapshots_file"
}

update_images_snapshots

git add .
# Check if there are actually changes before committing
if ! git diff-index --quiet HEAD; then
git commit -m "Update HCO bundle registry with new images"
git pull --rebase origin main
git push origin main
else
echo "No changes detected in the bundle registry. Skipping git push."
fi

if [[ "$(params.SNAPSHOT)" == *"hco-bundle-registry"* ]]; then
REPO_REVISION=$(jq -r '.spec.components[].source.git.revision' <<< "$SNAPSHOT_DATA")

BUNDLE_VERSION=$(cat build-bundle.json | jq -r '.metadata.Version | "\(.XY).\(.Z)-\(.release)" | sub("^v"; "")')
echo -n "$BUNDLE_VERSION" > /tekton/results/bundle-version

# Make sure we are getting the exact snapshots from the bundle
git checkout $REPO_REVISION

# Update the bundle snapshot as its not updated in this commit
update_images_snapshots

SNAPSHOTS_TO_RELEASE=$(cat $snapshots_file)
echo -n "$SNAPSHOTS_TO_RELEASE" > /tekton/results/snapshots-to-release
fi
- name: push-release-chart
image: quay.io/redhat-user-workloads/ocp-virt-images-tenant/pipeline-tools@sha256:18f9f819e9393891ce7ae19414a5672786e3efb120bdeaa2c254d8ba5d8e2493
envFrom:
- secretRef:
name: hco-updater-gitlab-token
- secretRef:
name: quay-builds-creds
volumeMounts:
- name: quay-creds
mountPath: /tmp/quay-builds-creds
readOnly: true
script: |
#!/usr/bin/env bash
set -eo pipefail

# Only continue if its releasing hco-bundle-registry
if [[ "$(params.SNAPSHOT)" != *"hco-bundle-registry"* ]]; then
echo "Skipping push-release-chart: snapshot parameter does not contain 'hco-bundle-registry'"
exit 0
fi

# Read results from previous step
SNAPSHOTS_TO_RELEASE=$(cat /tekton/results/snapshots-to-release)
BUNDLE_VERSION=$(cat /tekton/results/bundle-version)
XY=$(echo "$BUNDLE_VERSION" | cut -d'.' -f1,2 | tr '.' '-')

TMPDIR=$(mktemp -d)
cd "$TMPDIR"
export HOME=/tmp
git clone https://gitlab.cee.redhat.com/openshift-virtualization/konflux-builds/release-chart.git --depth 1
cd release-chart/release-orchestrator
yq -i ".version = \"$BUNDLE_VERSION\"" Chart.yaml
yq -i ".global.releasePlan = \"TODO-RELEASEPLAN\"" values.yaml
yq -i ".global.targetNamespace = \"v${XY}-openshift-virtualization-tenant\"" values.yaml

# Update values.yaml with snapshots from SNAPSHOTS_TO_RELEASE
echo "$SNAPSHOTS_TO_RELEASE" | jq -r '{snapshots: .}' | yq eval -P '.' > /tmp/snapshots_with_key.yaml
yq eval-all '. as $item ireduce ({}; . * $item)' values.yaml /tmp/snapshots_with_key.yaml -i

DOCKER_CONFIG=$(cat /tmp/quay-builds-creds/.dockerconfigjson)
QUAY_USERNAME=$(echo "${DOCKER_CONFIG}" | jq -r '.auths | to_entries[] | select(.key | contains("quay.io")) | .value.username')
QUAY_PASSWORD=$(echo "${DOCKER_CONFIG}" | jq -r '.auths | to_entries[] | select(.key | contains("quay.io")) | .value.password')
QUAY_URL=$(echo "${DOCKER_CONFIG}" | jq -r '.auths | to_entries[] | .key')

echo "${QUAY_PASSWORD}" | helm registry login quay.io --username "${QUAY_USERNAME}" --password-stdin

PACKAGE_OUTPUT=$(helm package . 2>&1)
PACKAGE_FILE=$(echo "${PACKAGE_OUTPUT}" | grep -oP 'Successfully packaged chart and saved it to: \K.*')

helm push $PACKAGE_FILE oci://${QUAY_URL}