verify:plan-job:has-warning-state fails due to unauthenticated request on non-public instances/projects
Summary
The verify:plan-job:has-warning-state job fails on private instances where the pipelines/jobs aren't public.
To be exact it is the following lines:
endpoint="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/pipelines/${CI_PIPELINE_ID}/jobs"
is_warning_job=$(curl --silent "$endpoint" | jq -r '.[] | select(.name == "validate") | [.status == "failed", .allow_failure == true] | all')
Steps to reproduce
Run the pipeline in a repository where the pipelines and job states are not public.
What is the current bug behavior?
I added an echo which returns the curl result which is: {"message":"404 Project Not Found"}, therefore the jq command fails with: jq: error (at <stdin>:1): Cannot index string with string "name".
This happens because the curl request is unauthenticated.
What is the expected correct behavior?
The curl request should be authenticated so that it can get the state of the previous job.
Results of GitLab environment info
The GitLab instance is a private (only authenticated access) with the Version: GitLab Enterprise Edition v18.5.1-ee
Possible fixes
One option I see is to authenticate the curl request, unfortunately the CI/CD token can't be used from what I can tell as it doesn't have the permissions to see other jobs in the pipeline: https://docs.gitlab.com/ci/jobs/ci_job_token/#job-token-access