From e71cbb17fa7258b45fe313f3d832c3658afacaa0 Mon Sep 17 00:00:00 2001 From: Muneeb Zia <31257991+Muneeb147@users.noreply.github.com> Date: Wed, 23 Oct 2024 03:11:09 +0500 Subject: [PATCH] Update dump-ci-stats-to-gcp-logs.js --- source/dump-ci-stats-to-gcp-logs.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/source/dump-ci-stats-to-gcp-logs.js b/source/dump-ci-stats-to-gcp-logs.js index 8704c66..6af935a 100644 --- a/source/dump-ci-stats-to-gcp-logs.js +++ b/source/dump-ci-stats-to-gcp-logs.js @@ -1,4 +1,4 @@ -// const fetch = require('node-fetch'); +const fetch = require('node-fetch'); const fs = require('fs'); // Capture input parameter (e.g., "Test Job") @@ -39,7 +39,12 @@ async function fetchWorkflowDetails() { createdAt: data.created_at, updatedAt: data.updated_at, actor: data.actor.login, // Who triggered the workflow - repository: data.repository.full_name + repository: data.repository.full_name, + event: data.event, // e.g., "push", "pull_request" + runAttempt: data.run_attempt, // Attempt number (for retries) + headBranch: data.head_branch, // The branch that triggered the workflow + headSha: data.head_sha, // The commit SHA that triggered the workflow + triggeredBy: data.actor.login // The user who triggered the workflow }; return workflowDetails; @@ -75,7 +80,18 @@ async function fetchJobDetails() { startedAt: job.started_at, completedAt: job.completed_at, executionTime: job.completed_at ? - (new Date(job.completed_at) - new Date(job.started_at)) / 1000 : null // In seconds + (new Date(job.completed_at) - new Date(job.started_at)) / 1000 : null, // In seconds + runnerName: job.runner_name, // The name of the runner + steps: job.steps.map(step => ({ + stepName: step.name, + status: step.status, // e.g., "completed" + conclusion: step.conclusion, // e.g., "success", "failure" + startedAt: step.started_at, + completedAt: step.completed_at, + executionTime: step.completed_at ? + (new Date(step.completed_at) - new Date(step.started_at)) / 1000 : null // In seconds + })), + jobUrl: job.html_url // Link to the job details page })); return jobDetails;