Run next stage despite failure (but still fail build)

We are using a fairly dated enterprise travis version that doesn’t use workspaces yet. So after hacking a workspaces implementation with shell scripts and github. I have finally encountered a problem I can’t figure out.

I want my report stage to run even if the previous integration stages failed but I still want to fail the build.

       - stage: integration
       - stage: integration 

       - stage: reports # I want this stage to run regardless of failure in the integration

What I’ve tried

  1. allow_failures does not satisfy this requirement as it will not fail the build if my integration tests fail
  2. Move report section into after_failure after_sucess in each job. This is not possible due to concurent builds. It creates a race condition ie. I need a final_after_failure which waits until all runners are complete, and one failed.
  3. before_deploy this is not possible for us as our deploy only takes place on master branch, wheras the reports should be generated on every branch

From your description, I gather that your requirements are:

  1. The reports job needs some things from the jobs in integration to report stuff on.
  2. The reports job needs to run regardless of the results of the integration jobs.
  3. Exactly when both integration jobs pass, the whole build should pass.

Note that the last two points are somewhat at odds with each other. We don’t have that kind of logic in build stages progression; in order to move on to the next stage, the previous stage has to pass. This is not dependent on the availability of workspaces to your Enterprise installation.

At any rate, we will need a small hack to fake an IPC that will allow the integration jobs to signal the reports job (and therefore the whole build) how the build’s result should be set. Workspaces will make things much simpler, I believe, but it should not be impossible without it.

  1. Set up an external storage that acts as a medium for the integration tests to upload their artifacts, and for the reports to pull them down. Workspaces will provide this.
  2. Allow integration jobs to fail.
  3. Do not allow the reports job to fail.
  4. Add a semaphore file in the build artifacts from the integration jobs that indicate their build results.
  5. At the end of the reports job, read the semaphore files, and report the result accordingly; if and only if both integration test passed, the reports job should exit with zero status.
1 Like

Thank you for your reply!

I ended up doing exactly that. My one fear of allowing failures was that the integration jobs would appear green even if they failed but this is not actually the case.

I basically did exactly as you described, I create a simple failed file, save my workspace (using a temporary branch), pull this workspace down in the report job and fail if this file is detected.