9

I've trying to do a setup, where I use Travis CI (http://www.travis-ci.org) to build and test my program each time I commit to GitHub. My GitHub setup is to have a master and a slave/test branch, which I commit to before merging into master. However, as of right now I'm doing the merging manually on GitHub.com, which I could like to automate, such that when a build is successful on Travis, I want to merge my slave/test branch into the master right away. Does anybody know how this is possible on Travis CI or another way of achieving this with Travis?

1 Answer 1

8

You can prepare script which will use for merge your branches. Travis set some useful environment variables which you can use in your script.

Merge script can look like:

if [ "$TRAVIS_BRANCH" != "test" ]; then 
    exit 0;
fi

export GIT_COMMITTER_EMAIL=...
export GIT_COMMITTER_NAME=...

git checkout master || exit
git merge "$TRAVIS_COMMIT" || exit
git push ... # here need some authorization and url

Next you can put in .travis.yml

after_success: ./merge_script.sh

More info:

1
  • 3
    in my experience, commands like git checkout some-branch will fail in Travis-CI.
    – tadasajon
    May 18, 2017 at 17:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.