I noticed on build https://travis-ci.org/neverendingqs/openssl-self-signed-certificate/builds/187723295 that I forgot to increase the patch version when tagging the repo. However, the build reported as passing
even though the npm publish failed due to the version already existing.
Here's the tail end of the log:
Deploying application
NPM API key format changed recently. If your deployment fails, check your API key in ~/.npmrc.
http://docs.travis-ci.com/user/deployment/npm/
~/.npmrc size: 48
npm ERR! publish Failed PUT 403
npm ERR! Linux 4.8.12-040812-generic
npm ERR! argv "/home/travis/.nvm/v0.10.48/bin/node" "/home/travis/.nvm/v0.10.48/bin/npm" "publish"
npm ERR! node v0.10.48
npm ERR! npm v2.15.1
npm ERR! code E403
npm ERR! "You cannot publish over the previously published version 1.1.5." : openssl-self-signed-certificate
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /home/travis/build/neverendingqs/openssl-self-signed-certificate/npm-debug.log
No stash found.
Done. Your build exited with 0.
In case it's important, I have the test
script in packages.json
set to exit 0
, but that occurs before the publish phase, so that shouldn't be the problem(?).
Why didn't Travis CI report the build a failure when the publish failed?
EDIT:
I used the Travis CI CLI to set up NPM publishing by running travis setup npm
, based on https://docs.travis-ci.com/user/deployment/npm/.
My .travis.yml
looks like this:
language: node_js
deploy:
provider: npm
email: myemail
api_key:
secure: blahblahblah
on:
tags: true
repo: neverendingqs/openssl-self-signed-certificate
Your script must have exited with an exit status of 0. This is the only thing that Travis cares about.
If you are running a script that does:
Then it should do:
or something like that, to make sure that the script with that command exits with a non-zero status if the
npm publish
command fails.You didn't include any example of your code but this is what I suspect may be happening here.
Actually it's even more complicated that that. Let's say that you have one script,
script1
that fails:And you have another script,
script2
that runs it:then running
./script2
will also result in error - running this:will print ERROR. But when you have another command later:
then running
./script2
this time will not return error this time. Running:will print OK.
So if your
npm publish
is the last command in your script then it should result in the entire script returning an error status to the system, but if it's not then the system will get a status of 0 meaning success.It all depends on how the script that Travis is running actually looks like.