Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 5

get status of multiple jobs in the same workflow

Solved! Go to Solution.

Hello folks,

I have the workflow that contains 3 jobs, and I want to have 4th job that will send a slack message for me.

Could you please advise how to get the status of all jobs and their statuses that currently is on workflow.

The suggestion about putting all the jobs in one not an option

name: CI
on:
  push:
    branches:
      - master
jobs:
  one:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - run: echo "one"
  two:
    runs-on: ubuntu-latest
    steps:
      - run: echo "two"
  five:
    runs-on: ubuntu-latest
    needs: [one, two]
    if: always()
    steps:
      - run: echo "How to know the status of execution of jobs.one and jobs.two?"
4 Replies
Highlighted
Copilot Lvl 2
Message 2 of 5

Re: get status of multiple jobs in the same workflow

The one thing that I found is using of Check API https://developer.github.com/v3/activity/events/types/#checksuiteevent

but this approach looks like a dirty workaround

Highlighted
Solution
GitHub Partner
Message 3 of 5

Re: get status of multiple jobs in the same workflow

Now, github actions provide workflow jobs APIs , you could use it to list all the jobs of a workflow run. 

https://developer.github.com/v3/actions/workflow_jobs/#list-jobs-for-a-workflow-run

And there is an environment variable GITHUB_RUN_ID you could use to get the current workflow run id. 

You could get the conclusion element value for job status. 

job conclusion.png

 

There is another method to pass job status through artifacts, for more information, please check BrightRan's solution here: 

https://github.community/t5/GitHub-Actions/How-get-the-status-of-previous-jobs/m-p/45511#M6237 

Highlighted
Copilot Lvl 3
Message 4 of 5

Re: get status of multiple jobs in the same workflow

Take a look at the Workflow Conclusion Action. It checks the status of the other jobs in your workflows, and will create an environment variable with a rolled up status. It works well if you need to do something conditionally on the basis of the other jobs.

 

https://github.com/marketplace/actions/workflow-conclusion-action

Highlighted
Copilot Lvl 3
Message 5 of 5

Re: get status of multiple jobs in the same workflow

Did you find a reasonable solution to this?