Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

travis-after-all

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

travis-after-all

Simple script that can help you execute code only once in a Travis CI build matrix

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
230
decreased by-48.2%
Maintainers
1
Weekly downloads
 
Created
Source

travis-after-all

Build Status devDependency Status

travis-after-all is a simple script that can help you execute code only once in a build matrix based on whether the build has succeeded or failed.

Or to put it in another way, travis-after-all is basically a temporary workaround for: travis-ci/travis-ci#929.

Usage

[1] Include the command that executes the travis-after-all script inside after_script (or inside of a script that is included inside after_script).

[2] Based on the exit code of travis-after-all, run your custom code

See examples.

--

Exit codes meaning:

  • 0 - the job that gets this exit code is the one assigned to run the code if the build succeeded

  • 1 - the job that gets this exit code is the one assigned to run the code if the build failed

  • other - job was not assigned to do anything

--

Terminology:

  • a job passed if either the tests passed or the tests failed but the job was allowed to fail

  • a build succeeded if all jobs passed and there is at least one job who's tests passed

  • a build failed if there is at least one job who didn't pass, or if all jobs passed but for all of them the tests failed

Usage examples

Using npm

Install travis-afer-all as a devDependency:

npm install --save-dev travis-after-all

then, in your .travis.yml file, add:


# ...

after_script:
  - |

      declare exitCode;


      # -- [1] -------------------------------------------------------

      $(npm bin)/travis-after-all
      exitCode=$?


      # -- [2] -------------------------------------------------------

      if [ $exitCode -eq 0 ]; then
        # Here goes the code that needs to be executed if the build succeeded
      fi

      if [ $exitCode -eq 1 ]; then
        # Here goes the code that needs to be executed if the build failed
      fi


# ...

You can also run travis-afer-all from within your node script, e.g.:

var travisAfterAll = require('travis-after-all');

function callback(exitCode, error) {

    if ( error ) {
       // ...
    } else {
        if ( exitCode === 0 ) {
          // Here goes the code that needs to be executed if the build succeeded
        } else if ( exitCode === 1) {
          // Here goes the code that needs to be executed if the build failed
        }
    }

}

travisAfterAll(callback);

General usage

In your .travis.yml file add:


# ...

after_script:
  - |

      declare exitCode


      # -- [1] -------------------------------------------------------

      curl -sSL https://raw.githubusercontent.com/alrra/travis-after-all/1.0.0/lib/travis-after-all.js | node
      exitCode=$?


      # -- [2] -------------------------------------------------------

      if [ $exitCode -eq 0 ]; then
        # Here goes the code that needs to be executed if the build succeeded
      fi

      if [ $exitCode -eq 1 ]; then
        # Here goes the code that needs to be executed if the build failed
      fi

# ...

Note: travis-after-all is written in JavaScript, however, since Travis includes the Node runtime by default, it can be use no matter what build environment you use.

License

The code is available under the MIT license.

Keywords

FAQs

Package last updated on 08 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc