4

I am using travis for building my project. I am having a deploy script something like below,

deploy:
  provider: script
  script:
    - npm run deploy
    - npm run test:deploy-results
  skip-cleanup: true
  on:
    branch: build

Here is how the npm script in package.json looks like,

"test:deploy-results": "node ./scripts/deploy-test-reports.js",

Travis is failing with status code 127. I tried to find some info but couldn't get any.

Sivasankar
  • 753
  • 8
  • 22

3 Answers3

3

After reading more, I figured it out that it is a Linux error code for not able to find the interpreter/compiler or missing executable.

Also, I need to add multiple deploy provider for executing multiple scripts in .travis.yml like below

deploy:
  skip_cleanup: true
  # Publish docs
  provider: script
  script: npm run test:deploy-results
  on:
    branch: build
  # Test reports
  provider: script
  script: npm run test:deploy-results
  on:
    branch: build
German Attanasio
  • 22,217
  • 7
  • 47
  • 63
Sivasankar
  • 753
  • 8
  • 22
3

If you want to execute multiple scripts, you can also bundle them in a single shell script (like scripts/deploy.sh) and execute this one in your deploy step:

.travis.yml

deploy:
  provider: script
  script: bash scripts/deploy.sh
  on:
    branch: master

scripts/deploy.sh

#!/bin/bash

echo 'Hello'
echo 'World'

It is equivalent to:

.travis.yml

deploy:
  - provider: script
    script: echo 'Hello'
    on:
      branch: master
  - provider: script
    skip_cleanup: true
    script: echo 'World'
    on:
      branch: master

Tip: Make sure to use LF line endings in the shell script, otherwise you will receive this error:

scripts/deploy.sh: line 2: $'\r': command not found

Happens often with Windows systems because they use CRLF line endings.

Benny Code
  • 51,456
  • 28
  • 233
  • 198
0

I got this because I was using a script that was not executable by Travis. Changing the permissions before executing solved it for me.

Something like this:

script: chmod +x scripts/deploy.sh && scripts/deploy.sh
Touré Holder
  • 2,768
  • 2
  • 22
  • 20
  • I also had this issue and realised it after moving the script out of the deploy and into the script section (which threw `/home/travis/.travis/functions: line 109: script.sh: Permission denied.`). You can commit the file with the correct permissions using `git update-index --add --chmod=+x build.sh` - https://stackoverflow.com/a/42187039 – harvzor Feb 11 '22 at 11:07