Replies: 3 comments 11 replies
-
There are API endpoints that require this; it's odd how hard it is to retrieve. Agree it should be exposed as an environment variable. Fwiw, here's what we did to get it: name: ${{ join(matrix.*, ' - ') }}
env:
JOB_NAME: ${{ join(matrix.*, ' - ') }}
steps:
- uses: actions/github-script@7a5c598405937d486b0331594b5da2b14db670da # v6
with:
script: |
const assert = (x, ...args) => { if (!x) { throw console.assert(x, ...args) } }
// https://octokit.github.io/rest.js/v18#actions-list-jobs-for-workflow-run-attempt
let jobs = await github.rest.actions.listJobsForWorkflowRunAttempt({
owner: context.payload.repository.owner.login,
repo: context.payload.repository.name,
run_id: context.runId,
attempt_number: process.env.GITHUB_RUN_ATTEMPT,
per_page: 100,
})
assert(jobs.status === 200 && jobs.data)
jobs = jobs.data.jobs
jobs = jobs.filter(job => job.name === process.env.JOB_NAME)
assert(jobs.length === 1)
const job_id = jobs[0].id;
return job_id |
Beta Was this translation helpful? Give feedback.
-
Hi all – I tried some of the workarounds, but we quickly got rate limited, since we have 80 test shards each with their own job, and we push a lot of code, so I guess we went over the default tier for API requests here. It'd be really great to get that job ID in an env var – we're building some tooling that links directly to a failing test shard (vs the CI suite as a whole), and this would be a huge UX improvement when using GitHub actions. Thanks! |
Beta Was this translation helpful? Give feedback.
-
There's an older discussion around this, where the GitHub team recently indicated that they are actively working on implementing this feature 🥳 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Select Topic Area
Product Feedback
Body
Hello,
Building upon Expose GITHUB_JOB_ID as an environment variable, I would make the case here to the product team to finally give us access to the job id (numerical, e.g.
26515583698
) generated by GitHub when creating a new workflow job.Exposing in workflow definitions
Currently we only get access to the job's Run ID through
${{ github.run_id }}
, but it is not enough in case we want to:Exposing in actions runner
Currently, when using self-hosted runners AFAIK there is absolutely no way to know which specific job is being executed by the runner.
GITHUB_RUN_ID
is currently set, but it would be great if we could also access the job ID. This would help a lot with troubleshooting.Thanks for considering the request, and please let me know if you need further details.
Beta Was this translation helpful? Give feedback.
All reactions