# The travis job terminated successfully, but after\_failure is called

**URL:** <https://travis-ci.community/t/the-travis-job-terminated-successfully-but-after-failure-is-called/13727>\
**Category:** Travis CI Discussions & Feedback\
**Tags:** bug\
**Created:** [March 29, 2023, 3:43am UTC](https://travis-ci.community/t/the-travis-job-terminated-successfully-but-after-failure-is-called/13727 "2023-03-29T03:43:14Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![younggi-crema](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/younggi-crema/32/8652_2.png) [@younggi-crema](https://travis-ci.community/u/younggi-crema)\
**Post date:** [March 29, 2023, 3:43am UTC](https://travis-ci.community/t/the-travis-job-terminated-successfully-but-after-failure-is-called/13727/1 "2023-03-29T03:43:14Z")

</div>

This is a problem from yesterday  
The SCRIPT part of TRAVIS’s JOB succeeds and runs fine, but I’m having an issue where AFTER\_FAILURE is always called.  
echo “${TRAVIS\_TEST\_RESULT}” after each step, but they all return 0 as normal.

```auto
$ echo "${TRAVIS_TEST_RESULT}"
0
The command "echo "${TRAVIS_TEST_RESULT}"" exited with 0.
cache.2
store build cache
after_failure.1
0.00s$ echo "${TRAVIS_TEST_RESULT}"
0
after_failure.2
35.14s$ gem install curb
after_failure.3
0.68s$ test/bin/cancel-other-jobs

```

---

<div class="post-metadata">

**Author:** ![gurnben](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/gurnben/32/8654_2.png) [@gurnben](https://travis-ci.community/u/gurnben)\
**Post date:** [March 29, 2023, 1:03pm UTC](https://travis-ci.community/t/the-travis-job-terminated-successfully-but-after-failure-is-called/13727/2 "2023-03-29T13:03:27Z")

</div>

We’re also seeing this same exact issue - it started around 6AM Eastern on March 28, 2023. With no changes to our scripts or travis.yml, all f our jobs returned 0 and ran the after\_failure:

```auto
The command "INSTALL_MODE="install" ./canary-scripts/deploy.sh" exited with 0.
$ ./canary-scripts/failure.sh

```

We’ve reached out to Travis Support!

---

<div class="post-metadata">

**Author:** ![xmao-mdsol](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/xmao-mdsol/32/8657_2.png) [@xmao-mdsol](https://travis-ci.community/u/xmao-mdsol)\
**Post date:** [March 29, 2023, 8:41pm UTC](https://travis-ci.community/t/the-travis-job-terminated-successfully-but-after-failure-is-called/13727/3 "2023-03-29T20:41:01Z")

</div>

We also seeing the same issue started at around 6AM yesterday. Both the after\_success.yml and after\_failure.yml scripts were run

```auto
$ bin/travis/after_success.sh
after_failure
$ bin/travis/after_failure.sh
Done. Your build exited with 0.

```

---

<div class="post-metadata">

**Author:** ![alishersadikov](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/alishersadikov/32/8651_2.png) [@alishersadikov](https://travis-ci.community/u/alishersadikov)\
**Post date:** [March 30, 2023, 2:21pm UTC](https://travis-ci.community/t/the-travis-job-terminated-successfully-but-after-failure-is-called/13727/4 "2023-03-30T14:21:14Z")

</div>

We experienced the same issue. We had to delete our after\_failure step to avoid this unexpected behavior. Are we right thinking that TRAVIS\_TEST\_RESULT decides if this step fires?

---

<div class="post-metadata">

**Author:** ![Montana](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/montana/32/9566_2.png) [@Montana](https://travis-ci.community/u/Montana)\
**Post date:** [March 30, 2023, 4:51pm UTC](https://travis-ci.community/t/the-travis-job-terminated-successfully-but-after-failure-is-called/13727/5 "2023-03-30T16:51:42Z")

</div>

Hi everyone, as we’re looking into the issue, here’s the current workaround:

```yml
after_success:
  - "[[$TRAVIS_TEST_RESULT = 0]] && echo passed"
after_failure:
  - "[[$TRAVIS_TEST_RESULT = 1]] && echo failed"

```

---

<div class="post-metadata">

**Author:** ![dholdren](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/dholdren/32/8696_2.png) [@dholdren](https://travis-ci.community/u/dholdren)\
**Post date:** [April 20, 2023, 3:42pm UTC](https://travis-ci.community/t/the-travis-job-terminated-successfully-but-after-failure-is-called/13727/6 "2023-04-20T15:42:33Z")

</div>

We’ve encountered this as well. no update after 3 weeks?

---

<div class="post-metadata">

**Author:** ![howtotalktogirls](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/howtotalktogirls/32/8432_2.png) [@howtotalktogirls](https://travis-ci.community/u/howtotalktogirls)\
**Post date:** [April 20, 2023, 8:59pm UTC](https://travis-ci.community/t/the-travis-job-terminated-successfully-but-after-failure-is-called/13727/7 "2023-04-20T20:59:15Z")

</div>

look at @montana’s reply here on this thread: [TRAVIS\_BUILD\_STAGE\_NAME not populated - #5 by Montana](https://travis-ci.community/t/travis-build-stage-name-not-populated/13768/5)

---

<div class="post-metadata">

**Author:** ![convenient](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/convenient/32/5750_2.png) [@convenient](https://travis-ci.community/u/convenient)\
**Post date:** [April 27, 2023, 12:50pm UTC](https://travis-ci.community/t/the-travis-job-terminated-successfully-but-after-failure-is-called/13727/8 "2023-04-27T12:50:01Z")

</div>

Adding here as it seems likely linked. we’re seeing a weird thing where each of the jobs from our stage are being pumped through `after_success` even though they had failed.

---

<div class="post-metadata">

**Author:** ![Montana](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/montana/32/9566_2.png) [@Montana](https://travis-ci.community/u/Montana)\
**Post date:** [April 27, 2023, 6:03pm UTC](https://travis-ci.community/t/the-travis-job-terminated-successfully-but-after-failure-is-called/13727/9 "2023-04-27T18:03:55Z")

</div>

Hi @convenient,

We are currently investigating.

---

<div class="post-metadata">

**Author:** ![convenient](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/convenient/32/5750_2.png) [@convenient](https://travis-ci.community/u/convenient)\
**Post date:** [April 28, 2023, 9:30am UTC](https://travis-ci.community/t/the-travis-job-terminated-successfully-but-after-failure-is-called/13727/10 "2023-04-28T09:30:17Z")

</div>

Yeah thanks @Montana , was just adding the comment here for completeness

---

<div class="post-metadata">

**Author:** ![jrg](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/jrg/32/8078_2.png) [@jrg](https://travis-ci.community/u/jrg)\
**Post date:** [April 19, 2024, 8:40am UTC](https://travis-ci.community/t/the-travis-job-terminated-successfully-but-after-failure-is-called/13727/11 "2024-04-19T08:40:26Z")

</div>

(Only found this thread when I went to write my own post).

There’s a worse, possibly connected issue. Deployment steps are being run even when the test (“script”) stage fails.

How long does it take to fix what is a potentially catastrophic problem, if a deployment succeeds after tests failed?

We first noticed it happening around 2024-04-11, though further investigation showed it had happened a couple of days before then. It’s 2024-04-19 and it’s still happening.

It also means that deployment scripts are needlessly being run, just wasting lots of CPU cycles and lots of time.

---

<div class="post-metadata">

**Author:** ![Montana](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/montana/32/9566_2.png) [@Montana](https://travis-ci.community/u/Montana)\
**Post date:** [April 22, 2024, 5:20pm UTC](https://travis-ci.community/t/the-travis-job-terminated-successfully-but-after-failure-is-called/13727/12 "2024-04-22T17:20:23Z")

</div>

Hi all,

Try this:

```yaml
deploy:
  ...
  on:
    condition: $TRAVIS_TEST_RESULT = 0

```

This should have the build pass.

---

<div class="post-metadata">

**Author:** ![AronNovak](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/aronnovak/32/9227_2.png) [@AronNovak](https://travis-ci.community/u/AronNovak)\
**Post date:** [May 21, 2024, 10:57am UTC](https://travis-ci.community/t/the-travis-job-terminated-successfully-but-after-failure-is-called/13727/13 "2024-05-21T10:57:50Z")

</div>

We still experience this. Is it a known issue that we must workaround?

---

<div class="post-metadata">

**Author:** ![Montana](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/montana/32/9566_2.png) [@Montana](https://travis-ci.community/u/Montana)\
**Post date:** [May 21, 2024, 6:53pm UTC](https://travis-ci.community/t/the-travis-job-terminated-successfully-but-after-failure-is-called/13727/14 "2024-05-21T18:53:30Z")

</div>

Hi all,

We are working on a fix for it as we speak.
