Skip to content

Run step based on which previous step failed #26969

Discussion options

You must be logged in to vote

Hi @jeffersonbledsoe , 

You could use steps.<step id>.outcome to get the step result.  And you could use if conditional in the upload artifacts step, add always() in addition to let the step to run even if previous step failed.  

if: always() && steps.step2.outcome == ‘failure’

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
     - name: step1
       run: echo "hello 1"
       id: step1
       continue-on-error: true
     - name: step2
       run: |
          echo "hello 2"
          fff
       id: step2
       #continue-on-error: true
     - name: step3
       if: always() && steps.step2.outcome == 'failure'
       run: echo "hello 3"
       id: step3

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants