Skip to content
Draft
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
fec0285
Try use CEL in task
msugakov Apr 15, 2026
9041246
Try with env
msugakov Apr 15, 2026
c4df4d4
Try change env to param
msugakov Apr 15, 2026
ae8ce3d
Try add cel: prefix
msugakov Apr 15, 2026
a63e68f
Simplify the expression
msugakov Apr 15, 2026
bf256a0
Try inline
msugakov Apr 15, 2026
f1154c4
Try un-pac. per the bot's suggestion
msugakov Apr 15, 2026
b2b4d01
Next step: simple boolean expression
msugakov Apr 15, 2026
c491d20
Try quote differently
msugakov Apr 15, 2026
e8416b5
Try add `cel:`
msugakov Apr 15, 2026
cec482a
Add more diagnostic
msugakov Apr 15, 2026
28a6ef4
Add more diagnostic
msugakov Apr 15, 2026
d109483
Switch to event_type
msugakov Apr 15, 2026
e8052b5
Add target branch
msugakov Apr 15, 2026
1cf49c2
Add source_branch to the mix
msugakov Apr 15, 2026
fb7166f
Add body.pull_request to the mix
msugakov Apr 15, 2026
4b2c4d1
Revert "Add body.pull_request to the mix"
msugakov Apr 15, 2026
b9ae19d
More slowly add body
msugakov Apr 15, 2026
a93cd68
Move on with body
msugakov Apr 15, 2026
bb3bceb
Add full label expression
msugakov Apr 15, 2026
81538e6
try see what's `pull_request_number`
msugakov Apr 15, 2026
0b3758d
Output body
msugakov Apr 15, 2026
ce5fda9
Try find label through issue
msugakov Apr 15, 2026
98ca902
fix
msugakov Apr 15, 2026
df667fb
Try translate to bash
msugakov Apr 15, 2026
8fbbaf8
fix boolean
msugakov Apr 15, 2026
1db18c0
Try resolve is_pull_request
msugakov Apr 15, 2026
1a08988
try reduce code
msugakov Apr 15, 2026
155f3e5
Refine and plug the task
msugakov Apr 15, 2026
a86311c
fix newline
msugakov Apr 15, 2026
1b841de
describe, add label activation
msugakov Apr 15, 2026
3e6f9fb
Move description
msugakov Apr 15, 2026
eed076f
beautify
msugakov Apr 15, 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
91 changes: 82 additions & 9 deletions .tekton/create-custom-snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,13 @@ metadata:
build.appstudio.redhat.com/target_branch: '{{target_branch}}'
pipelinesascode.tekton.dev/max-keep-runs: "500"
pipelinesascode.tekton.dev/on-comment: "/konflux-retest create-custom-snapshot"
# Unlike other pipelines, this one is enabled for all PRs. See the description of determine-actual-build task.
# The condition for a label is to make sure the konflux-build label addition activates this pipeline, same as others.
# TODO(ROX-21073): re-enable for all PR branches
pipelinesascode.tekton.dev/on-cel-expression: |
(
event == "push" && target_branch.matches("^(master|release-.*|refs/tags/.*)$")
) || (
event == "pull_request" && (
target_branch.startsWith("release-") ||
source_branch.matches("(konflux|renovate|appstudio|rhtap)") ||
(has(body.pull_request) && has(body.pull_request.labels) && body.pull_request.labels.exists(l, l.name == "konflux-build"))
) && body.action != "ready_for_review"
)
(event == "push" && target_branch.matches("^(master|release-.*|refs/tags/.*)$")) ||
(event == "pull_request" && body.action != "ready_for_review") ||
(has(body.pull_request) && has(body.pull_request.labels) && body.pull_request.labels.exists(l, l.name == "konflux-build"))
# The empty `on-label` annotation is a workaround to make sure the pipeline gets triggered when the label gets first
# added to the PR. See the Slack tread linked from ROX-30580.
pipelinesascode.tekton.dev/on-label: "[]"
Expand Down Expand Up @@ -124,6 +120,67 @@ spec:
- name: post-metric-start
taskRef: *post-bigquery-metrics-ref

# TODO: event_type=on-comment and the rest
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is "the rest"?

- name: determine-actual-build
taskSpec:
description: |
Determines whether the actual tasks in the pipeline should be skipped or executed.
Tasks will be skipped on PRs where Konflux builds aren't enabled (TODO: ROX-21073), see
`pipelinesascode.tekton.dev/on-cel-expression` annotation in `*-build.yaml` files.
This all is needed because we want to always run this `create-custom-snapshot` pipeline and make it part of
required GitHub checks in branch protection rules.
results:
- name: SHOULD_REALLY_WORK
steps:
- name: determine
image: registry.redhat.io/ubi9-minimal:latest@sha256:fe688da81a696387ca53a4c19231e99289591f990c904ef913c51b6e87d4e4df
# The script expresses the same condition as pipelinesascode.tekton.dev/on-cel-expression in other pipelines
# but in a more verbose way because, as it turns out, both syntax and fields of CEL expressions are slightly
# different.
script: |
set -euo pipefail

function assert_boolean() {
if [[ "${2:-}" != "" ]]; then
echo "${2}"
fi
echo "${1}: ${!1}"
if [[ "${!1}" != "true" && "${!1}" != "false" ]]; then
>&2 echo "Error: not a boolean value: ${!1}"
exit 2
fi
}

is_pull_request="false"
[[ "{{ pull_request_number }}" == "" ]] || is_pull_request="true"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also saw that the pull request number was literally "{{ pull_request_number }}"

assert_boolean is_pull_request "pull_request_number: {{ pull_request_number }}"

is_matching_target_branch='{{ cel: target_branch.startsWith("release-") }}'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is interesting. Can {{ cel: ...}} be used anywhere? Are there other templating sources documented?

assert_boolean is_matching_target_branch "target_branch: {{ target_branch }}"

is_matching_source_branch='{{ cel: source_branch.matches("(konflux|renovate|appstudio|rhtap)") }}'
assert_boolean is_matching_source_branch "source_branch: {{ source_branch }}"

has_konflux_build_label_as_pr='{{ cel: has(body.pull_request) && has(body.pull_request.labels) && body.pull_request.labels.exists(l, l.name == "konflux-build") }}'
assert_boolean has_konflux_build_label_as_pr

has_konflux_build_label_as_issue='{{ cel: has(body.issue) && has(body.issue.labels) && body.issue.labels.exists(l, l.name == "konflux-build") }}'
assert_boolean has_konflux_build_label_as_issue

result="false"
if [[ "${is_pull_request}" != "true" || "${is_matching_target_branch}" == "true" || "${is_matching_source_branch}" == "true" || "${has_konflux_build_label_as_pr}" == "true" || "${has_konflux_build_label_as_issue}" == "true" ]]; then
result="true"
fi
echo -n "The result is: "
echo -n "${result}" | tee "$(results.SHOULD_REALLY_WORK.path)"
echo

echo '-----------'
echo 'full body, for diagnostics if anything fails:'
cat <<EOF
{{ cel: body }}
EOF

- name: clone-repository
params:
- name: url
Expand All @@ -150,6 +207,10 @@ spec:
workspaces:
- name: basic-auth
workspace: git-auth
when:
- input: $(tasks.determine-actual-build.results.SHOULD_REALLY_WORK)
operator: in
values: [ "true" ]

- name: determine-image-tag
params:
Expand All @@ -166,6 +227,10 @@ spec:
- name: kind
value: task
resolver: bundles
when:
- input: $(tasks.determine-actual-build.results.SHOULD_REALLY_WORK)
operator: in
values: [ "true" ]

- name: wait-for-bundle-image
params:
Expand All @@ -182,6 +247,10 @@ spec:
resolver: bundles
# The timemout should be kept in sync with the pipeline timeout in the operator-bundle-build.yaml
timeout: 3h25m
when:
- input: $(tasks.determine-actual-build.results.SHOULD_REALLY_WORK)
operator: in
values: [ "true" ]

- name: create-acs-style-snapshot
params:
Expand Down Expand Up @@ -269,3 +338,7 @@ spec:
- name: kind
value: task
resolver: bundles
when:
- input: $(tasks.determine-actual-build.results.SHOULD_REALLY_WORK)
operator: in
values: [ "true" ]
Loading