travis-ci is the brilliant ideas for Continuous Integration in Cloud, it is the must have for the opensource project if you host it in github.
When you push the code into github, and trigger the build. Travis-ci load the default Ubunut 12.04 virtual machines (VirtualBox tech) and run your defined scripts from .travis-ci.yml to “build” your product, after the build, the virtual machine will be destroyed at once.
One big shortcome is travis-ci doesn’t provide the “archive feature” natively to help you to transfer the build result to other machines like jenkins.
Originally you need to write own scripts to upload your own hosted servers, and since all the build script and information is public, how to make your own secure (like password to access your own host) is tricky.
Fortunately it is solved in very nice and clear way though it doesn’t provide archive feature still.
The solution is Github API+"Secure environment variables"
Github already provide the “Repo Download API” to help you to upload the files to your “Download” page in your repo. http://developer.github.com/v3/repos/downloads/
You could use the curl command to fetch the token, and the script github-upload.rb from https://github.com/wereHamster/ghup will help you do the rest
See README there directly since it is simple.
Secure environment variables
“Secure environment variables” is the feature provided in travis, it helps you to secure your information (like passwd or private key) in elegant way. You need use travis command (from travis gem) to encrypt your information and get token as the key to get that information like below
$ gem install travis $ travis encrypt larrycai/sdcamp GITHUB_TOKEN=66b79b8c91e236b16ab99d88cb3379839ce98d25 About to encrypt 'GITHUB_TOKEN=66b79b8c91e236b16ab99d88cb3379839ce98d25' for 'larrycai/sdcamp' Please add the following to your .travis.yml file: secure: "qkE5/TVKQV/+xBEW5M7ayWMMtFwhu44rQb9zh3n0LH4CkVb+b748lOuW3htc\nXfnXU8aGzOsQBeCJZQstfzsHFPkll+xfhk38cFqNQp7tpMo/AOZIkqd2AIUL\n0bgaFD+1kFAxKTu02m11xzkDNw6FuHMVvoMEQu/fo115i2YmWHo="
In travis-ci build, you need to indicate the token to ask system to fetch your information.， Since the token is connected to your account and repo, it is safe.
Then using the varible inside the
env: global: - secure: "qkE5/TVKQV/+xBEW5M7ayWMMtFwhu44rQb9zh3n0LH4CkVb+b748lOuW3htc\nXfnXU8aGzOsQBeCJZQstfzsHFPkll+xfhk38cFqNQp7tpMo/AOZIkqd2AIUL\n0bgaFD+1kFAxKTu02m11xzkDNw6FuHMVvoMEQu/fo115i2YmWHo=" after_script: - ./github-upload.rb sdcamp.zh.pdf larrycai/sdcamp --description "generated by travis-ci, $TRAVIS_JOB_ID" --force --name sdcamp.zh.snapshot.pdf --skip-ssl-verification -t $GITHUB_TOKEN
Hope you enjoy the solution.