toolkit icon indicating copy to clipboard operation
toolkit copied to clipboard

needs.<job id>.result is using steps conclusion instead of outcome

Open tleveque69 opened this issue 5 years ago • 5 comments

Thank you 🙇‍♀ for wanting to create an issue in this repository. Before you do, please ensure you are filing the issue in the right place. Issues should only be opened on if the issue relates to code in this repository.

If your issue is relevant to this repository, please include the information below:

Describe the bug I've been trying to use needs context However if ever your job has continue on error flag set to true and you check the job result via the needs context you'll get success while the job actually fails

To Reproduce Steps to reproduce the behavior:

  1. Create a failing jobs with continue-on-error set to true
  2. Create another job needing the first one and try to access the first job result

Expected behavior Expected needs.job1.result to be failure even if flag continue-on-error is set to true

name: Test download Input
on:
  push:
      branches:    
      - master
jobs:
  job1:
    runs-on: ubuntu-latest
    continue-on-error: true
    steps:
      - name: "Check if artifact has already been built"
        id: dwnld
        uses: actions/download-artifact@v2
        with:
          name: ${{ steps.get-commit.outputs.commit }}_${{ matrix.apps }}
      - name: The job has failed
        if: ${{ failure() }}
        run: echo fails
  build_artifact:
    runs-on: ubuntu-latest
    needs: [job1]
    steps:
      - run: echo ${{ needs.job1.result }}

Capture d’écran 2020-09-23 à 16 18 22

tleveque69 avatar Sep 23 '20 14:09 tleveque69

Any update on this issue? It has been a while. This thing break my use case. Now I can't use status for branch protection.

##Update

I did more test on this. I think it only happens in certain edge cases. In general, it still work as expected.

https://github.com/maxisam/create-summary-check-status/actions/runs/1885906626

However, I did have a weird case that it doesn't work like it should.

maxisam avatar Feb 22 '22 23:02 maxisam

@maxisam I just happened to stumble upon this as I've experienced the same issue. What did you mean that this is an edge case? I reproduced it with:

name: Test

on: push

jobs:
  job1:
    runs-on: ubuntu-latest
    continue-on-error: true
    steps:
      - run: exit 1

  job2:
    runs-on: ubuntu-latest
    needs: job1
    if: needs.job1.result == 'success'
    steps:
      - run: echo ${{needs.validate.result}}

Both jobs always run, because job1 result is always seen as success even though it is failed and marked as such in the UI.

Does not seem like an edge case 🤔

ldaneliukas avatar Sep 06 '23 08:09 ldaneliukas

@ldaneliukas any workaround for your mentioned case? The only idea for now is defining an output on job1, and checking for that output on job if condition.

cfoch avatar Nov 15 '23 16:11 cfoch

@ldaneliukas any workaround for your mentioned case? The only idea for now is defining an output on job1, and checking for that output on job if condition.

No, not really and there doesn't seem to be any response to this, so we just live with it (i.e. we don't use this 'feature').

ldaneliukas avatar Nov 16 '23 10:11 ldaneliukas

In the docs it says job.<job_id>.result is only for reusable workflows 👎 :

The jobs context is only available in reusable workflows, and can only be used to set outputs for a reusable workflow. For more information, see "Reusing workflows."

wburgess-sdx avatar Oct 31 '24 14:10 wburgess-sdx