I´m currently developing a simple java project stored in a github repository with maven to build it and Travis-ci to build it automatically after pushing changes to the repository. My teacher demands that, after an automatic successful build made by travis-ci, I zip the whole project and store it. I´ve already accomplished zipping the project with maven. It brings my zip file to the src/main/resources of my project so I can push the ziip file in my github repository. But when travis creates the zip file, it won´t push the zip to my repository in github. Instead, it generates the zip file to /home/travis/build/my-user/...
That´s what it says in the travis terminal: [INFO] Building zip: /home/travis/build/fabiophillip/calculadoralib/src/main/resources/CalculadoraLib-0.0.1-SNAPSHOT-assembly.zip
How can I make travis-ci push this zip to my github repository instead of this travis folder which I don´t know how to access?
You could use what I do in this answer (to another question) .
you just need to zip up your project and have it be the file that is deployed to github releases on all tagged commits.
To zip the folder:
cd to the folders repository
zip whatyouwanttonamethezip
This copies the current directory, including all subdirectories into the archive file.
That will create this button on the tags/releases tab of your git repo.
When a Tag is created and pushed the config below will do the following:
I'm using PHP but the steps should work the same.
dist: trusty
language: php
php: 7.1
env:
global:
- REPO=api
matrix:
- BUILD_ENV=test
- BUILD_ENV=qa
install:
- composer install --no-interaction
branches:
# expected format: v1.0.0
only:
- /^v\d+(\.\d+)+$/
before_deploy:
- cd ..
- tar -zcf ${TRAVIS_BUILD_DIR}${REPO}-${BUILD_ENV}-${TRAVIS_TAG}-${TRAVIS_BUILD_NUMBER}.tar.gz ${REPO}
deploy:
# GitHub - Add zip to release
- provider: releases
api_key:
secure: "YOUR GITHUB API KEY"
file: ${TRAVIS_BUILD_DIR}${REPO}-${BUILD_ENV}-${TRAVIS_TAG}-${TRAVIS_BUILD_NUMBER}.tar.gz
skip_cleanup: true
on:
tags: true
To upload a zip to GitHub you can either commit back to the repo or use GitHub releases which require working with tags.
What I would recommend is uploading your zip to AWS S3 .
You can upload to S3 from Travis by following these instructions Here is a short example that you can add to your .travis.yml
:
deploy:
provider: s3
access_key_id: "YOUR AWS ACCESS KEY"
secret_access_key: "YOUR AWS SECRET KEY"
bucket: "S3 Bucket"
skip_cleanup: true
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.