3

I'm trying to build some branch "travis" with travis and then push it to the master branch of my github personal site repository. What I get, when building is

The command "./build.sh" exited with 1.

Done. Your build exited with 1

But Travis doesn't give me any real error. I am able to build the site locally. Here is a complete log:

https://travis-ci.org/DavidSanwald/DavidSanwald.github.io/builds/184261084

This is my build.sh script:

#!/bin/bash

# only proceed script when started not by pull request (PR)
if [ $TRAVIS_PULL_REQUEST == "true" ]; then
  echo "this is PR, exiting"
  exit 0
fi

# enable error reporting to the console
set -e

# build site with jekyll, by default to `_site' folder
bundle exec jekyll build
#find ./_site -name "*.html" -exec bundle exec htmlbeautifier {} \;
#bundle exec htmlproof ./_site --disable-external --check-html --verbose

# cleanup
rm -rf ../DavidSanwald.github.io.master

#clone `master' branch of the repository using encrypted GH_TOKEN for authentification
git clone https://${GH_TOKEN}@github.com/DavidSanwald/DavidSanwald.github.io.git ../DavidSanwald.github.io.master

# copy generated HTML site to `master' branch
cp -R _site/* ../DavidSanwald.github.io.master

# commit and push generated content to `master' branch
# since repository was cloned in write mode with token auth - we can push there
cd ../DavidSanwald.github.io.master
git config user.email "davidsanwald@users.noreply.github.com"
git config user.name "DavidSanwald"
git add -A .
git commit -a -m "Travis #$TRAVIS_BUILD_NUMBER"
git push --quiet origin master > /dev/null 2>&1

This is my .travis.yml:

sudo: required
language: ruby
before_script:
- chmod a+x ./build.sh
script: "./build.sh"
branches:
  only:
  - travis
rbenv:
- 2.2.3
env:
  global:
  - secure: "long encrypted env variables"

I tried several things but I'm kind of lost because I can't even find a helpful error message to begin, also I can build everything locally. So I don't know where to start.

edit: Okay, removed the --quiet option and they redirect of the output. No I get:

error: src refspec master does not match any.
error: failed to push some refs to 'https://f0f6a53cbfafecf9a0ccdd4d5121b5ca75f09cfd@github.com/DavidSanwald/DavidSanwald.github.io.git'

That's a starting point. Will come back if I solved it. Any ideas are still appreciated though. Revoked the token above. It's just in here for demonstration.

I_like_foxes
  • 1,179
  • 1
  • 7
  • 12

1 Answers1

1

Try a git status just before the git push.

That error message means either there is no commit (unlikely here), or refs/heads/master is not available.

Try git push origin HEAD:master to see if that works.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks! You were right. Did `git show-ref` and my refs were messed up. – I_like_foxes Dec 19 '16 at 15:43
  • Unfortunately fetching or `git update-ref` didn't resolve it right away. Tried a lot of things and I'm not even sure what finally did the trick (sorry, accidentally submitted my comment and can't edit it to add the rest) – I_like_foxes Dec 19 '16 at 15:49