[quick checks/validate_pipelines] Fix list of changed files (#219150)

Fixes an issue where `validate_pipelines.sh` could attempt to validate a
pipeline file that does not exist.

The check was looking for changed files comparing `elastic/kibana/main`
and the pull request branch, where an out of date pull request could
return a changed file that was not modified in the pr branch.

See
https://buildkite.com/elastic/kibana-pull-request/builds/295938#019668ee-99f0-409e-bd7d-466e6293e982
This commit is contained in:
Jon 2025-04-24 17:09:08 -05:00 committed by GitHub
parent 442cf9b7be
commit fc226cc198
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -10,7 +10,7 @@ check_for_changed_files "$cmd" true
if [[ "${BUILDKITE_PULL_REQUEST_BASE_BRANCH:-}" != "" ]]; then
echo --- Check if all new pipelines are valid
AFFECTED_PIPELINES=$(git diff "$BUILDKITE_PULL_REQUEST_BASE_BRANCH" --name-only | \
AFFECTED_PIPELINES=$(gh pr view "$BUILDKITE_PULL_REQUEST" --json files --jq '.files.[].path' | \
grep -E '^.buildkite/pipeline-resource-definitions/.*\.yml$' | \
grep -Ev '(/locations.yml|_templates)' || true)
echo "Pipelines affected by this PR: $AFFECTED_PIPELINES"