0

I am converting a Jenkins declarative pipeline into a GitHub Actions workflow. We rely on the following bit of code in the pipeline to override the status of our Protractor test stage by checking the output of a series of txt files with booleans in for whether a scenario passed or failed:

            } catch (err) {
              testFlags = sh(script:'cat *result.flag.txt', returnStdout: true).trim()
             if (testFlags.contains('true')) {
               println "A test failure exists - build status updated to failure"
               currentBuild.result = 'FAILURE'
               error "Test(s) have failed"
              }
              else {
                println "No test failures exist - build status updated to success"

I am trying to figure out a way to do something similar in a Github Actions .yml file? The code for generating the txt files is the same and I believe is working.

The reason we need to do this is due to a bug with Cucumber.js where even if a Scenario fails once then passes on retry the exit code is still 1. So we have to override it and set the flag files for each test.

Phonesis
  • 323
  • 3
  • 12
  • Does this answer your question: https://stackoverflow.com/questions/57903836/how-to-fail-a-job-in-github-actions? – riQQ Mar 31 '20 at 16:17
  • I think that is definitely along right lines! Not sure how to implement the stdout bit though to check the txt file output – Phonesis Mar 31 '20 at 16:37
  • You can use any of the supported `shells`: https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-a-specific-shell – riQQ Mar 31 '20 at 16:46

0 Answers0