How to publish artifacts in Travis CI?

后端 未结 10 1867
一向
一向 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:18

    The first question you should ask yourself is whether you want to publish artifacts from CI builds or whether you want to deploy releases (i.e. to GitHub).

    Since there are plenty of answers here regarding uploading releases to GitHub, I will not tackle this topic further.

    If you want to get hold of snapshot/CI build artifacts, the easiest way is to have them uploaded to AWS S3. Unfortunately, the documentation for this is a bit rough, especially when you are unexperienced with AWS. So here is what you have to do:

    1. Create a AWS IAM user for Travis

    To do so, go to https://console.aws.amazon.com/iam/home?#/users and create a new user account for Travis with type Programmatic access. Grant it access to S3 by applying the existing policy AmazonS3FullAccess on the permissions tab.

    Once the user is created make sure to copy the Access Key ID as well the secret access key for that user!

    2. Create a AWS S3 Bucket for Travis to upload to

    That one is pretty straight forward. Only thing to watch out for is to avoid Signature v4-only regions like us-east-2, eu-central-1, etc. (because of https://github.com/travis-ci/artifacts/issues/57). A solid choice is us-east-1, which also happens to be the default expected by Travis and thus saves you a little additional configuration. Of course you can also use an existing bucket that meets this requirement.

    3. Add environment variables to Travis CI repository settings

    Next, go to the settings for your repository in Travis. Create the following new environment variables:

    ARTIFACTS_KEY=(AWS access key id from step 1)
    ARTIFACTS_SECRET=(AWS secret access key from step 1)
    ARTIFACTS_BUCKET=(S3 bucket name from step 2)
    

    4. Enable artifacts addon

    Finally, in your repository add the following lines to the .travis.yml in order to activate the artifacts addon

    addons:
      artifacts: true
    

    If everything went well, you should see your build artifacts popping up in the S3 bucket. You may want to adjust the paths being scanned and so on, as desecribed in the documentation.

    Hope that helps someone or another.

提交回复
热议问题