From 155d5458b888f6bc9e571ef076d1226e30aecc1d Mon Sep 17 00:00:00 2001 From: Elai Shalev Date: Thu, 19 Feb 2026 15:35:33 +0200 Subject: [PATCH 1/2] First draft - tracking commit ID --- .../migrations/2025012401_create_jobs_table.ts | 1 + .../plugins/x2a-backend/src/router/collectArtifacts.ts | 3 +++ .../x2a/plugins/x2a-backend/src/schema/openapi.yaml | 6 ++++++ .../src/schema/openapi/generated/models/Job.model.ts | 4 ++++ .../ProjectsProjectIdCollectArtifactsPostRequest.model.ts | 4 ++++ .../x2a-backend/src/schema/openapi/generated/router.ts | 8 ++++++++ .../x2a-backend/src/services/X2ADatabaseService/index.ts | 1 + .../src/services/X2ADatabaseService/jobOperations.ts | 7 +++++++ .../src/services/X2ADatabaseService/mappers.ts | 1 + .../x2a/plugins/x2a-backend/templates/x2a-job-script.sh | 7 +++++++ .../src/schema/openapi/generated/models/Job.model.ts | 4 ++++ .../ProjectsProjectIdCollectArtifactsPostRequest.model.ts | 4 ++++ workspaces/x2a/plugins/x2a-common/report.api.md | 2 ++ workspaces/x2a/plugins/x2a/report.api.md | 1 + .../plugins/x2a/src/components/ModulePage/PhasesCard.tsx | 6 ++++++ workspaces/x2a/plugins/x2a/src/translations/de.ts | 1 + workspaces/x2a/plugins/x2a/src/translations/es.ts | 1 + workspaces/x2a/plugins/x2a/src/translations/fr.ts | 1 + workspaces/x2a/plugins/x2a/src/translations/it.ts | 1 + workspaces/x2a/plugins/x2a/src/translations/ref.ts | 1 + 20 files changed, 64 insertions(+) diff --git a/workspaces/x2a/plugins/x2a-backend/migrations/2025012401_create_jobs_table.ts b/workspaces/x2a/plugins/x2a-backend/migrations/2025012401_create_jobs_table.ts index 5f474232ee..dafa7c94a9 100644 --- a/workspaces/x2a/plugins/x2a-backend/migrations/2025012401_create_jobs_table.ts +++ b/workspaces/x2a/plugins/x2a-backend/migrations/2025012401_create_jobs_table.ts @@ -41,6 +41,7 @@ export async function up(knex: Knex): Promise { table.text('telemetry'); // JSON-serialized Telemetry object table.string('k8s_job_name'); table.string('callback_token'); + table.string('commit_id').nullable(); table .uuid('project_id') .notNullable() diff --git a/workspaces/x2a/plugins/x2a-backend/src/router/collectArtifacts.ts b/workspaces/x2a/plugins/x2a-backend/src/router/collectArtifacts.ts index d80d700b92..0d9cc57bb9 100644 --- a/workspaces/x2a/plugins/x2a-backend/src/router/collectArtifacts.ts +++ b/workspaces/x2a/plugins/x2a-backend/src/router/collectArtifacts.ts @@ -61,6 +61,7 @@ const collectArtifactsRequestSchema = z.object({ jobId: z.string().uuid('Job ID must be a valid UUID'), artifacts: z.array(artifactSchema).optional(), telemetry: telemetrySchema.optional(), + commitId: z.string().optional(), }); export interface CollectArtifactsRequestBody { @@ -69,6 +70,7 @@ export interface CollectArtifactsRequestBody { jobId: string; artifacts?: Artifact[]; telemetry?: Telemetry; + commitId?: string; } export function registerCollectArtifactsRoutes( @@ -164,6 +166,7 @@ export function registerCollectArtifactsRoutes( log: logs, artifacts: validatedRequest.artifacts || [], telemetry: validatedRequest.telemetry || null, + commitId: validatedRequest.commitId, }); logger.info( diff --git a/workspaces/x2a/plugins/x2a-backend/src/schema/openapi.yaml b/workspaces/x2a/plugins/x2a-backend/src/schema/openapi.yaml index 5db545f6ab..8b1d8661d3 100644 --- a/workspaces/x2a/plugins/x2a-backend/src/schema/openapi.yaml +++ b/workspaces/x2a/plugins/x2a-backend/src/schema/openapi.yaml @@ -432,6 +432,9 @@ paths: $ref: '#/components/schemas/Artifact' telemetry: $ref: '#/components/schemas/Telemetry' + commitId: + type: string + description: Git commit SHA from the job's push to target repo required: - status - jobId @@ -665,6 +668,9 @@ components: $ref: '#/components/schemas/Artifact' telemetry: $ref: '#/components/schemas/Telemetry' + commitId: + type: string + description: Git commit SHA produced by this job ArtifactType: type: string diff --git a/workspaces/x2a/plugins/x2a-backend/src/schema/openapi/generated/models/Job.model.ts b/workspaces/x2a/plugins/x2a-backend/src/schema/openapi/generated/models/Job.model.ts index abc863e10e..e413ee1e6d 100644 --- a/workspaces/x2a/plugins/x2a-backend/src/schema/openapi/generated/models/Job.model.ts +++ b/workspaces/x2a/plugins/x2a-backend/src/schema/openapi/generated/models/Job.model.ts @@ -61,4 +61,8 @@ export interface Job { */ artifacts?: Array; telemetry?: Telemetry; + /** + * Git commit SHA produced by this job + */ + commitId?: string; } diff --git a/workspaces/x2a/plugins/x2a-backend/src/schema/openapi/generated/models/ProjectsProjectIdCollectArtifactsPostRequest.model.ts b/workspaces/x2a/plugins/x2a-backend/src/schema/openapi/generated/models/ProjectsProjectIdCollectArtifactsPostRequest.model.ts index 565d594ef0..c36c7ac9d7 100644 --- a/workspaces/x2a/plugins/x2a-backend/src/schema/openapi/generated/models/ProjectsProjectIdCollectArtifactsPostRequest.model.ts +++ b/workspaces/x2a/plugins/x2a-backend/src/schema/openapi/generated/models/ProjectsProjectIdCollectArtifactsPostRequest.model.ts @@ -41,6 +41,10 @@ export interface ProjectsProjectIdCollectArtifactsPostRequest { */ artifacts?: Array; telemetry?: Telemetry; + /** + * Git commit SHA from the job's push to target repo + */ + commitId?: string; } /** diff --git a/workspaces/x2a/plugins/x2a-backend/src/schema/openapi/generated/router.ts b/workspaces/x2a/plugins/x2a-backend/src/schema/openapi/generated/router.ts index 9d2931c0e3..80fc920cd5 100644 --- a/workspaces/x2a/plugins/x2a-backend/src/schema/openapi/generated/router.ts +++ b/workspaces/x2a/plugins/x2a-backend/src/schema/openapi/generated/router.ts @@ -649,6 +649,10 @@ export const spec = { }, "telemetry": { "$ref": "#/components/schemas/Telemetry" + }, + "commitId": { + "type": "string", + "description": "Git commit SHA from the job's push to target repo" } }, "required": [ @@ -939,6 +943,10 @@ export const spec = { }, "telemetry": { "$ref": "#/components/schemas/Telemetry" + }, + "commitId": { + "type": "string", + "description": "Git commit SHA produced by this job" } } }, diff --git a/workspaces/x2a/plugins/x2a-backend/src/services/X2ADatabaseService/index.ts b/workspaces/x2a/plugins/x2a-backend/src/services/X2ADatabaseService/index.ts index 12b6b01009..c64f456c78 100644 --- a/workspaces/x2a/plugins/x2a-backend/src/services/X2ADatabaseService/index.ts +++ b/workspaces/x2a/plugins/x2a-backend/src/services/X2ADatabaseService/index.ts @@ -337,6 +337,7 @@ export class X2ADatabaseService { k8sJobName?: string | null; artifacts?: Artifact[]; telemetry?: Telemetry | null; + commitId?: string; }): Promise { return this.#jobOps.updateJob(update); } diff --git a/workspaces/x2a/plugins/x2a-backend/src/services/X2ADatabaseService/jobOperations.ts b/workspaces/x2a/plugins/x2a-backend/src/services/X2ADatabaseService/jobOperations.ts index 3b75b236b6..728e948090 100644 --- a/workspaces/x2a/plugins/x2a-backend/src/services/X2ADatabaseService/jobOperations.ts +++ b/workspaces/x2a/plugins/x2a-backend/src/services/X2ADatabaseService/jobOperations.ts @@ -139,6 +139,7 @@ export class JobOperations { 'k8s_job_name', 'callback_token', 'telemetry', + 'commit_id', ) .first(); if (!row) { @@ -269,6 +270,7 @@ export class JobOperations { 'k8s_job_name', 'callback_token', 'telemetry', + 'commit_id', ) .orderBy('started_at', 'desc') .modify(queryBuilder => { @@ -295,6 +297,7 @@ export class JobOperations { k8sJobName, artifacts, telemetry, + commitId, }: { id: string; log?: string | null; @@ -304,6 +307,7 @@ export class JobOperations { k8sJobName?: string | null; artifacts?: Artifact[]; telemetry?: Telemetry | null; + commitId?: string; }): Promise { this.#logger.info(`updateJob called for id: ${id}`); @@ -332,6 +336,9 @@ export class JobOperations { if (telemetry !== undefined) { updateData.telemetry = telemetry ? JSON.stringify(telemetry) : null; } + if (commitId !== undefined) { + updateData.commit_id = commitId; + } if (Object.keys(updateData).length > 0) { await this.#dbClient('jobs').where('id', id).update(updateData); diff --git a/workspaces/x2a/plugins/x2a-backend/src/services/X2ADatabaseService/mappers.ts b/workspaces/x2a/plugins/x2a-backend/src/services/X2ADatabaseService/mappers.ts index 9e70638655..80c584258f 100644 --- a/workspaces/x2a/plugins/x2a-backend/src/services/X2ADatabaseService/mappers.ts +++ b/workspaces/x2a/plugins/x2a-backend/src/services/X2ADatabaseService/mappers.ts @@ -67,6 +67,7 @@ export function mapRowToJob( errorDetails: (row.error_details as string | undefined) ?? undefined, k8sJobName: (row.k8s_job_name as string) ?? undefined, callbackToken: (row.callback_token as string | undefined) ?? undefined, + commitId: (row.commit_id as string | undefined) ?? undefined, telemetry: parseTelemetry( (row.telemetry as string | undefined) ?? undefined, ), diff --git a/workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh b/workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh index e23f7ca64d..760f514f1f 100644 --- a/workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh +++ b/workspaces/x2a/plugins/x2a-backend/templates/x2a-job-script.sh @@ -9,6 +9,7 @@ ERROR_MESSAGE="" ARTIFACTS=() PUSH_FAILED="" TERMINATED=false +COMMIT_ID="" # Report job result back to the backend. # TODO: Incorporate CALLBACK_TOKEN for request signing (HMAC-SHA256). @@ -34,6 +35,10 @@ report_result() { cmd+=(--error-message "${message}") fi + if [ -n "${COMMIT_ID:-}" ]; then + cmd+=(--commit-id "${COMMIT_ID}") + fi + echo "Reporting result: status=${status}, phase=${PHASE}" cd /app && "${cmd[@]}" || echo "WARNING: Failed to report result to backend" } @@ -90,6 +95,8 @@ Co-Authored-By: ${GIT_AUTHOR_NAME} <${GIT_AUTHOR_EMAIL}> if ! git push origin "${TARGET_REPO_BRANCH}"; then PUSH_FAILED="Failed to push to ${TARGET_REPO_URL} branch ${TARGET_REPO_BRANCH}" echo "ERROR: ${PUSH_FAILED}" + else + COMMIT_ID=$(git rev-parse HEAD 2>/dev/null || echo "") fi fi diff --git a/workspaces/x2a/plugins/x2a-common/client/src/schema/openapi/generated/models/Job.model.ts b/workspaces/x2a/plugins/x2a-common/client/src/schema/openapi/generated/models/Job.model.ts index abc863e10e..e413ee1e6d 100644 --- a/workspaces/x2a/plugins/x2a-common/client/src/schema/openapi/generated/models/Job.model.ts +++ b/workspaces/x2a/plugins/x2a-common/client/src/schema/openapi/generated/models/Job.model.ts @@ -61,4 +61,8 @@ export interface Job { */ artifacts?: Array; telemetry?: Telemetry; + /** + * Git commit SHA produced by this job + */ + commitId?: string; } diff --git a/workspaces/x2a/plugins/x2a-common/client/src/schema/openapi/generated/models/ProjectsProjectIdCollectArtifactsPostRequest.model.ts b/workspaces/x2a/plugins/x2a-common/client/src/schema/openapi/generated/models/ProjectsProjectIdCollectArtifactsPostRequest.model.ts index 565d594ef0..c36c7ac9d7 100644 --- a/workspaces/x2a/plugins/x2a-common/client/src/schema/openapi/generated/models/ProjectsProjectIdCollectArtifactsPostRequest.model.ts +++ b/workspaces/x2a/plugins/x2a-common/client/src/schema/openapi/generated/models/ProjectsProjectIdCollectArtifactsPostRequest.model.ts @@ -41,6 +41,10 @@ export interface ProjectsProjectIdCollectArtifactsPostRequest { */ artifacts?: Array; telemetry?: Telemetry; + /** + * Git commit SHA from the job's push to target repo + */ + commitId?: string; } /** diff --git a/workspaces/x2a/plugins/x2a-common/report.api.md b/workspaces/x2a/plugins/x2a-common/report.api.md index 3293481700..1158d737db 100644 --- a/workspaces/x2a/plugins/x2a-common/report.api.md +++ b/workspaces/x2a/plugins/x2a-common/report.api.md @@ -83,6 +83,7 @@ export interface GitRepoAuth { // @public (undocumented) export interface Job { artifacts?: Array; + commitId?: string; errorDetails?: string; finishedAt?: Date; id: string; @@ -210,6 +211,7 @@ export interface ProjectsProjectIdCollectArtifactsPost200Response { // @public (undocumented) export interface ProjectsProjectIdCollectArtifactsPostRequest { artifacts?: Array; + commitId?: string; errorDetails?: string; jobId: string; status: ProjectsProjectIdCollectArtifactsPostRequestStatusEnum; diff --git a/workspaces/x2a/plugins/x2a/report.api.md b/workspaces/x2a/plugins/x2a/report.api.md index cd8368bba9..2cf120be9e 100644 --- a/workspaces/x2a/plugins/x2a/report.api.md +++ b/workspaces/x2a/plugins/x2a/report.api.md @@ -64,6 +64,7 @@ readonly "modulePage.phases.publishInstructions": string; readonly "modulePage.phases.runPublish": string; readonly "modulePage.phases.republishInstructions": string; readonly "modulePage.phases.rerunPublish": string; +readonly "modulePage.phases.commitId": string; readonly "modulePage.phases.viewLog": string; readonly "modulePage.phases.hideLog": string; readonly "project.id": string; diff --git a/workspaces/x2a/plugins/x2a/src/components/ModulePage/PhasesCard.tsx b/workspaces/x2a/plugins/x2a/src/components/ModulePage/PhasesCard.tsx index 6205f252d0..5442ac55c0 100644 --- a/workspaces/x2a/plugins/x2a/src/components/ModulePage/PhasesCard.tsx +++ b/workspaces/x2a/plugins/x2a/src/components/ModulePage/PhasesCard.tsx @@ -203,6 +203,12 @@ const PhaseDetails = ({ value={phase?.id || empty} /> + + + {phase && ( diff --git a/workspaces/x2a/plugins/x2a/src/translations/de.ts b/workspaces/x2a/plugins/x2a/src/translations/de.ts index 1722ce8476..8a029572de 100644 --- a/workspaces/x2a/plugins/x2a/src/translations/de.ts +++ b/workspaces/x2a/plugins/x2a/src/translations/de.ts @@ -115,6 +115,7 @@ const x2aPluginTranslationDe = createTranslationMessages({ 'Das Modul wurde bereits veröffentlicht. Lösen Sie die Veröffentlichung erneut aus, um das Ziel-Repository zu aktualisieren.', 'modulePage.phases.rerunPublish': 'Im Ziel-Repository erneut veröffentlichen', + 'modulePage.phases.commitId': 'Commit-ID', 'modulePage.phases.viewLog': 'Log anzeigen', 'modulePage.phases.hideLog': 'Log ausblenden', }, diff --git a/workspaces/x2a/plugins/x2a/src/translations/es.ts b/workspaces/x2a/plugins/x2a/src/translations/es.ts index c8a5f080fe..197ff89be1 100644 --- a/workspaces/x2a/plugins/x2a/src/translations/es.ts +++ b/workspaces/x2a/plugins/x2a/src/translations/es.ts @@ -117,6 +117,7 @@ const x2aPluginTranslationEs = createTranslationMessages({ 'El módulo ya ha sido publicado. Vuelva a ejecutar la publicación para actualizar el repositorio de destino.', 'modulePage.phases.rerunPublish': 'Volver a publicar en el repositorio de destino', + 'modulePage.phases.commitId': 'ID de commit', 'modulePage.phases.viewLog': 'Ver registro', 'modulePage.phases.hideLog': 'Ocultar registro', }, diff --git a/workspaces/x2a/plugins/x2a/src/translations/fr.ts b/workspaces/x2a/plugins/x2a/src/translations/fr.ts index 1c771b1f45..56b427eb65 100644 --- a/workspaces/x2a/plugins/x2a/src/translations/fr.ts +++ b/workspaces/x2a/plugins/x2a/src/translations/fr.ts @@ -114,6 +114,7 @@ const x2aPluginTranslationFr = createTranslationMessages({ 'modulePage.phases.republishInstructions': 'Le module a déjà été publié. Relancez la publication pour mettre à jour le dépôt cible.', 'modulePage.phases.rerunPublish': 'Republier dans le dépôt cible', + 'modulePage.phases.commitId': 'ID de commit', 'modulePage.phases.viewLog': 'Voir le journal', 'modulePage.phases.hideLog': 'Masquer le journal', }, diff --git a/workspaces/x2a/plugins/x2a/src/translations/it.ts b/workspaces/x2a/plugins/x2a/src/translations/it.ts index 45e1e7414e..095e06955c 100644 --- a/workspaces/x2a/plugins/x2a/src/translations/it.ts +++ b/workspaces/x2a/plugins/x2a/src/translations/it.ts @@ -118,6 +118,7 @@ const x2aPluginTranslationIt = createTranslationMessages({ 'Il modulo è già stato pubblicato. Riavvia la pubblicazione per aggiornare il repository di destinazione.', 'modulePage.phases.rerunPublish': 'Ripubblica nel repository di destinazione', + 'modulePage.phases.commitId': 'ID commit', 'modulePage.phases.viewLog': 'Visualizza log', 'modulePage.phases.hideLog': 'Nascondi log', }, diff --git a/workspaces/x2a/plugins/x2a/src/translations/ref.ts b/workspaces/x2a/plugins/x2a/src/translations/ref.ts index 0c6d30cf78..e3e791e4ba 100644 --- a/workspaces/x2a/plugins/x2a/src/translations/ref.ts +++ b/workspaces/x2a/plugins/x2a/src/translations/ref.ts @@ -69,6 +69,7 @@ export const x2aPluginMessages = { republishInstructions: 'The module has already been published. Retrigger the publish to update the target repository.', rerunPublish: 'Republish to target repository', + commitId: 'Commit ID', viewLog: 'View Log', hideLog: 'Hide Log', }, From 867db48d4ec3709c4ad482ee3a6322b4b02291dd Mon Sep 17 00:00:00 2001 From: Elai Shalev Date: Thu, 19 Feb 2026 16:00:00 +0200 Subject: [PATCH 2/2] name change --- workspaces/x2a/plugins/x2a/src/translations/de.ts | 2 +- workspaces/x2a/plugins/x2a/src/translations/es.ts | 2 +- workspaces/x2a/plugins/x2a/src/translations/fr.ts | 2 +- workspaces/x2a/plugins/x2a/src/translations/it.ts | 2 +- workspaces/x2a/plugins/x2a/src/translations/ref.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/workspaces/x2a/plugins/x2a/src/translations/de.ts b/workspaces/x2a/plugins/x2a/src/translations/de.ts index 8a029572de..b9c0f40258 100644 --- a/workspaces/x2a/plugins/x2a/src/translations/de.ts +++ b/workspaces/x2a/plugins/x2a/src/translations/de.ts @@ -115,7 +115,7 @@ const x2aPluginTranslationDe = createTranslationMessages({ 'Das Modul wurde bereits veröffentlicht. Lösen Sie die Veröffentlichung erneut aus, um das Ziel-Repository zu aktualisieren.', 'modulePage.phases.rerunPublish': 'Im Ziel-Repository erneut veröffentlichen', - 'modulePage.phases.commitId': 'Commit-ID', + 'modulePage.phases.commitId': 'Letzte Commit-ID', 'modulePage.phases.viewLog': 'Log anzeigen', 'modulePage.phases.hideLog': 'Log ausblenden', }, diff --git a/workspaces/x2a/plugins/x2a/src/translations/es.ts b/workspaces/x2a/plugins/x2a/src/translations/es.ts index 197ff89be1..8dd9fa6241 100644 --- a/workspaces/x2a/plugins/x2a/src/translations/es.ts +++ b/workspaces/x2a/plugins/x2a/src/translations/es.ts @@ -117,7 +117,7 @@ const x2aPluginTranslationEs = createTranslationMessages({ 'El módulo ya ha sido publicado. Vuelva a ejecutar la publicación para actualizar el repositorio de destino.', 'modulePage.phases.rerunPublish': 'Volver a publicar en el repositorio de destino', - 'modulePage.phases.commitId': 'ID de commit', + 'modulePage.phases.commitId': 'Ultimo ID de commit', 'modulePage.phases.viewLog': 'Ver registro', 'modulePage.phases.hideLog': 'Ocultar registro', }, diff --git a/workspaces/x2a/plugins/x2a/src/translations/fr.ts b/workspaces/x2a/plugins/x2a/src/translations/fr.ts index 56b427eb65..e53b93e2fa 100644 --- a/workspaces/x2a/plugins/x2a/src/translations/fr.ts +++ b/workspaces/x2a/plugins/x2a/src/translations/fr.ts @@ -114,7 +114,7 @@ const x2aPluginTranslationFr = createTranslationMessages({ 'modulePage.phases.republishInstructions': 'Le module a déjà été publié. Relancez la publication pour mettre à jour le dépôt cible.', 'modulePage.phases.rerunPublish': 'Republier dans le dépôt cible', - 'modulePage.phases.commitId': 'ID de commit', + 'modulePage.phases.commitId': 'Dernier ID de commit', 'modulePage.phases.viewLog': 'Voir le journal', 'modulePage.phases.hideLog': 'Masquer le journal', }, diff --git a/workspaces/x2a/plugins/x2a/src/translations/it.ts b/workspaces/x2a/plugins/x2a/src/translations/it.ts index 095e06955c..c3b1bb20d0 100644 --- a/workspaces/x2a/plugins/x2a/src/translations/it.ts +++ b/workspaces/x2a/plugins/x2a/src/translations/it.ts @@ -118,7 +118,7 @@ const x2aPluginTranslationIt = createTranslationMessages({ 'Il modulo è già stato pubblicato. Riavvia la pubblicazione per aggiornare il repository di destinazione.', 'modulePage.phases.rerunPublish': 'Ripubblica nel repository di destinazione', - 'modulePage.phases.commitId': 'ID commit', + 'modulePage.phases.commitId': 'Ultimo ID commit', 'modulePage.phases.viewLog': 'Visualizza log', 'modulePage.phases.hideLog': 'Nascondi log', }, diff --git a/workspaces/x2a/plugins/x2a/src/translations/ref.ts b/workspaces/x2a/plugins/x2a/src/translations/ref.ts index e3e791e4ba..6f7584e15c 100644 --- a/workspaces/x2a/plugins/x2a/src/translations/ref.ts +++ b/workspaces/x2a/plugins/x2a/src/translations/ref.ts @@ -69,7 +69,7 @@ export const x2aPluginMessages = { republishInstructions: 'The module has already been published. Retrigger the publish to update the target repository.', rerunPublish: 'Republish to target repository', - commitId: 'Commit ID', + commitId: 'Last Commit ID', viewLog: 'View Log', hideLog: 'Hide Log', },