ci: support for jobName flag and v3 messages#4288
Conversation
Signed-off-by: Miguel Pedro <miguel.pedro@precisioninno.com>
There was a problem hiding this comment.
Code Review
This pull request introduces a new --jobName command-line argument to uploadMetadata.py, enabling the emission of schema v3 payloads to Pub/Sub when a job name is provided. The review feedback suggests sanitizing the --jobName argument by stripping leading and trailing whitespaces. This ensures that empty or whitespace-only values do not incorrectly trigger schema v3, both when building the payload and when publishing the pipeline report.
| payload = { | ||
| "payload_schema_version": 3 if args.jobName else 2, |
There was a problem hiding this comment.
To prevent whitespace-only strings from triggering schema v3 with an invalid/empty job name, and to ensure robust handling of the --jobName argument, we should strip leading and trailing whitespaces and treat empty/whitespace-only values as None.
| payload = { | |
| "payload_schema_version": 3 if args.jobName else 2, | |
| job_name = args.jobName.strip() if args.jobName else None | |
| payload = { | |
| "payload_schema_version": 3 if job_name else 2, |
| if args.jobName: | ||
| payload["job_name"] = args.jobName |
| """Publish a pre-encoded v2 pipeline message.""" | ||
| """Publish a pre-encoded pipeline message (v3 when --jobName is set, else v2).""" | ||
| size_kb = len(message_data) / 1024 | ||
| schema_version = "3" if args.jobName else "2" |
Adds a
--jobNameargument toflow/util/uploadMetadata.pyso the QoR metadata published to Pub/Sub can carry the canonical Jenkins pipeline name. When the argument is supplied, the message is emitted as schema v3 (the existing v2 structure plus a top-leveljob_name); when it is omitted, the script behaves exactly as before and emits v2.This lets the palantir backend resolve the pipeline directly from job_name instead of classifying the raw BUILD_TAG with a hardcoded pattern table, so new pipelines appear on the dashboard without a backend code change.
What changed
--jobNameargument (defaults to None).build_pipeline_payloadsetspayload_schema_versionto 3 and adds job_name when --jobName is set; otherwise stays on 2. The backend requires a non-blankjob_namefor v3, so a blank value safely falls back to v2 and the legacy classifier.publish_pipeline_reportsets the Pub/Sub `payload_schema_version`` message attribute to match the body (3 or 2).