How to publish artifacts in Travis CI?

后端 未结 10 1889
一向
一向 2020-12-07 16:47

I would like to use Travis CI for my open-source project. The issue that Travis doesn\'t provide any ways to publish produced artifacts (though, they have this in their futu

10条回答
  •  被撕碎了的回忆
    2020-12-07 17:14

    So first you have to be sure that you try to deploy release artifacts. So make tag first in Github. To do it manually:

    Then in the .travis.yml file add the following configuration. For gradle users

    language: java
    jdk:
      - oraclejdk7
    
    sudo: required
    
    before_install:
     - chmod +x gradlew
    
    script:
      - ./gradlew clean build -i --continue
    
    deploy:
      provider: releases
      api_key: ${api_key}
      file: "build/libs/Project.jar"
      skip_cleanup: true
      on:
        all_branches: true
        tags: true
    

    Here api_key value is Travis Ci environment variable. Which points to Github api_key.

    file is the build artifact produced from the build. Which we want to be deployed to gitHub.

    on:
        all_branches: true
        tags: true
    

    is mandatory configuration for tags to be deployed.

    No you have to get the api_key from github:

    1. Go to Personal Access Tokens

    1. Choose Generate new token

    1. Select appropriate scopes for the api_key
    2. Copy the generated api_key
    3. Go to the Travis Ci and add environment variable. For that purpose choose Settings
      1. Paste the generated api_key

    When you trigger new build the artifact will be deployed.

提交回复
热议问题