travis-ci / artifacts

Travis CI Artifacts Uploader
MIT License
87 stars 24 forks source link

S3 bucket URL change? #87

Open theplankmeister opened 6 years ago

theplankmeister commented 6 years ago

It appears that the URL generated for each artifact is incorrect. The current format is https://s3.amazonaws.com/%s (as can be seen here where the supplied parameter is the bucket name) which, for example, generates https://s3.amazonaws.com/my-bucket/my-org/my-project/build/job/thisisthefile.png

However, when visiting a generated URL, I don't get the expected file, but rather this:

<Error>
   <Code>PermanentRedirect</Code>
   <Message>The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.</Message>
   <Bucket>my-bucket</Bucket>
   <Endpoint>my-bucket.s3.amazonaws.com</Endpoint>
   <RequestId>blahblahblah</RequestId>
   <HostId>blahblahblah</HostId>
</Error>

If I then manually modify the generated URL to:

https://my-bucket.s3.amazonaws.com/my-org/my-project/build/job/thisisthefile.png

then it works as expected.

So I'm guessing that the line of code linked to above, should actually be:

downloadHost = fmt.Sprintf("https://%s.s3.amazonaws.com/", b.Name)

...or is there something I'm missing?

rueckstiess commented 5 years ago

We are seeing the same issue. Our S3 bucket is in the ap-southeast-2 region, which is not in the default region (us-east-1) and therefore the URLs are different.

Note that just above the line @theplankmeister quoted is this assignment:

    downloadHost := s3p.getRegion().S3BucketEndpoint
    if downloadHost == "" {
        downloadHost = fmt.Sprintf("https://s3.amazonaws.com/%s", b.Name)
    }

and it only uses the default URL if downloadHost is empty. I'm wondering what s3p.getRegion().S3BucketEndpoint returns for non-default regions?

This issue has been open for a while, is there any update? It's a very useful feature to be able to get the URL in the log output and be able to download the artifacts.

Thanks!

basisbit commented 4 years ago

I can confirm this problem for https://travis-ci.org/UltraStar-Deluxe/Play/ where s3_region in the .travis-ci.yaml and ARTIFACTS_REGION are all set to "eu-west-1" but the download link url still points to https://s3.amazonaws.com/ultrastar.public.basisbit/...

theplankmeister commented 4 years ago

I made a PR, but it's been ignored for the past year... https://github.com/travis-ci/artifacts/pull/89