5

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?

  • Publish anywhere: http://stackoverflow.com/questions/12343452/how-to-publish-artifacts-in-travis-ci || to GH pages: http://stackoverflow.com/questions/23277391/how-to-publish-to-github-pages-from-travis-ci – Ciro Santilli OurBigBook.com Oct 13 '15 at 18:05
  • In a Maven project, input files reside in the `/src` directory and output files are created in the `/target` directory. See: https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html – Jens Piegsa May 21 '21 at 05:09

3 Answers3

3

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. enter image description here

Community
  • 1
  • 1
Noah Presler
  • 151
  • 4
1

When a Tag is created and pushed the config below will do the following:

  1. Travis will clone the repo (named "api")
  2. Repo is built
  3. Repo is zipped
  4. Zip is uploaded to GitHub as the tagged release download.

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
Justin
  • 26,443
  • 16
  • 111
  • 128
-2

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
Robert MacLean
  • 38,975
  • 25
  • 98
  • 152
joshua-anderson
  • 4,458
  • 5
  • 35
  • 56