Circle-Ci build failed

nodejs

#1

I am deploying my application at staging server. But it is failing during deployment and showing this error.

remote: -----> Building dependencies
remote: Installing node modules (package.json + package-lock)
remote: Unhandled rejection Error: Command failed: /usr/bin/git checkout 4.0
remote: error: pathspec ‘4.0’ did not match any file(s) known to git.
remote:
remote: at ChildProcess.exithandler (child_process.js:276:12)
remote: at emitTwo (events.js:126:13)
remote: at ChildProcess.emit (events.js:214:7)
remote: at maybeClose (internal/child_process.js:915:16)
remote: at Socket.stream.socket.on (internal/child_process.js:336:11)
remote: at emitOne (events.js:116:13)
remote: at Socket.emit (events.js:211:7)
remote: at Pipe._handle.close [as _onclose] (net.js:561:12)
remote: npm ERR! write after end
remote: npm ERR! write after end
remote: npm ERR! write after end
remote: npm ERR! write after end
remote: npm ERR! write after end
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.eZko6/_logs/2018-11-14T02_34_09_121Z-debug.log
remote:
remote: -----> Build failed
remote:
remote: We’re sorry this build is failing! You can troubleshoot common issues here:
remote: https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote: If you’re stuck, please submit a ticket so we can help:
remote: https://help.heroku.com/
remote:
remote: Love,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: Verifying deploy…
remote:
remote: ! Push rejected to drbeen-stage.
remote:
To https://heroku:ca3eaeab-23c3-40a2-947f-82bb98e68276@git.heroku.com/drbeen-stage.git
! [remote rejected] master -> master (pre-receive hook declined)

whats the issue? Kindly guide me about this.


#2

It looks like you don’t have a tag or branch called 4.0 as you expect. Please supply your config.yml in a formatted block so that readers stand a reasonable chance of being able to help - it is unlikely people can assist otherwise.

You may also need to explain how your deployment works e.g. whether you are using an ssh command, or a remote heroku command, etc.


#3

here is my config.yml for deployment

jobs:
build-and-test:
working_directory: ~/drbeen.com
docker:
- image: node:8
steps:
- checkout
- restore_cache:
key: drbeen-{{ arch }}-{{ .Branch }}-{{ checksum “package-lock.json” }}
- run:
name: install npm stuff
command: npm install
- save_cache:
key: drbeen-{{ arch }}-{{ .Branch }}-{{ checksum “package-lock.json” }}
paths:
- node_modules
# - run:
# name: test
# command: npm test
deploy-stage:
working_directory: ~/drbeen.com
docker:
- image: node:8
steps:
- checkout
- restore_cache:
key: drbeen-{{ arch }}-{{ .Branch }}-{{ checksum “package-lock.json” }}
- run:
name: install npm stuff
command: npm install
- save_cache:
key: drbeen-{{ arch }}-{{ .Branch }}-{{ checksum “package-lock.json” }}
paths:
- node_modules
# - run:
# name: test
# command: npm test
- deploy:
name: heroku setup
command: |
# wget https://cli-assets.heroku.com/branches/stable/heroku-linux-amd64.tar.gz -O heroku.tar.gz
# tar -xvzf heroku.tar.gz
# ./heroku/install
wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh
cat >~/.netrc <<EOF
machine api.heroku.com
login $HEROKU_EMAIL
password $HEROKU_TOKEN
machine git.heroku.com
login $HEROKU_EMAIL
password HEROKU_TOKEN EOF chmod 600 ~/.netrc ssh-keygen -R heroku.com ssh-keyscan -H heroku.com >> ~/.ssh/known_hosts - deploy: command: | heroku config:set COMMIT=(git rev-parse --short HEAD) --app drbeen-stage
git push --force https://heroku:$HEROKU_API_KEY@git.heroku.com/drbeen-stage.git master
#git push --force git@heroku.com:drbeen-stage.git $CIRCLE_SHA1:refs/heads/master
heroku run ./node_modules/migrate-mongo/bin/migrate-mongo.js -f config/index.js up --app drbeen-stage


#4

:slightly_smiling_face:


#5

This look like my actual case and also the followings:


Their solution was to disable cache of the .git folder before the checkout (to speedup checkout).
I’m sure it work but the checkout time can be long on some projects and their is no --depth configuration for git to save some data transfer.


#6

True, but the checkout command is optional - you can just use git if you are willing to do the checkout manually, which in turn will allow you to do a shallow clone.