Reputation: 803
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.
Upvotes: 4
Views: 3606
Reputation: 3506
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
Upvotes: 0
Reputation: 803
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
Upvotes: 3
Reputation: 54782
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.
Upvotes: 3