This will demonstrate how to upload build files from Travis CI to S3.
NOTE: Keys have been changed to protect the innocent.
Create an S3 ACL policy, see s3_policy.json for an example.
Use gen_upload_policy.php
to generate the base64 policy and
signature. This requires your S3 secret key to generate the signature:
$ ./gen_upload_policy.php ./s3_policy.json lvbpI6ICIyMDA4LTErLTAxVDtyO+m202n03
S3_POLICY="eyAiZXhwaXshdGlvbpI6ICIyMDA4LTErLTAxVDtyOjAwOjAwLjAsMFoiLAogICJjb25kaXRpb25zPjogWwoJeyJidWNrZXQiOiAiczNwaG90b3MubW9hcHAubmV0IiB9LAogICAgWyJzdGFydHMtd2l0aCIsICIka2V5IiwgIkxpdmVTaG90cy8iXSwKICAgIHsiYWNsIjogInB1YmxpYy1yZWFkIiB9LAoJWyJlcSIsICIkQ29udGVudC1UeXBlIiwgImltYWdlL2pwZWciXSwKICBdCn0K"
S3_SIGNATURE="20uh08kU75ADHL49NyhYRgZW8BY="
You'll use the S3_POLICY
and S3_SIGNATURE
variables in your .travis.yml
config file.
Take the variables from above and set them as environment variables in your .travis.yml
. Also set the S3_ACCESS_KEY
to your S3 access key (not the secret one) and S3_BUCKET
to the name of the S3 bucket. See the example .travis.yml file for details.
Create an upload script that uploads files to the appropriate S3 bucket. See the example s3_upload.sh that uploads all *.jar files under the top-level directory target/
to S3.
Add the script location to the .travis.yml
after_success hook.