Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins Continuous Integration with Amazon S3 - Everything is uploading to the root?

I'm running Jenkins and I have it successfully working with my Github account, but I can't get it working correctly with Amazon S3.

I installed the S3 plugin and when I run a build it successfully uploads to the S3 bucket I specify, but all of the files uploaded end up in the root of the bucket. I have a bunch of folders (such as /css /js and so on), but all of the files in those folders from hithub end up in the root of my S3 account.

Is it possible to get the S3 plugin to upload and retain the folder structure?

like image 310
Kris Anderson Avatar asked Jul 18 '12 06:07

Kris Anderson


People also ask

How does Jenkins integrate with Amazon S3?

Once S3 Publisher is installed properly we require to setup Amazon s3 profile to setup Amazon S3 profiles go to Manage jenkins >> Configure System >> Amazon S3 Proiles click on ADD to add S3 Profile give require details Profile name , access key , secret access key of the account using which we will upload the artifact ...

What is the max file size that we can upload to S3?

You can upload any file type—images, backups, data, movies, etc. —into an S3 bucket. The maximum size of a file that you can upload by using the Amazon S3 console is 160 GB. To upload a file larger than 160 GB, use the AWS CLI, AWS SDK, or Amazon S3 REST API.

How do I import a CSV file into an S3 bucket?

Navigate to All Settings > Raw Data Export > CSV Upload. Toggle the switch to ON. Select Amazon S3 Bucket from the dropdown menu. Enter your Access Key ID, Secret Access Key, and bucket name.


1 Answers

It doesn't look like this is possible. Instead, I'm using s3cmd to do this. You must first install it on your server, and then in one of the bash scripts within a Jenkins job you can use:

s3cmd sync -r -P $WORKSPACE/ s3://YOUR_BUCKET_NAME

That will copy all of the files to your S3 account maintaining the folder structure. The -P keeps read permissions for everyone (needed if you're using your bucket as a web server). This is a great solution using the sync feature, because it compares all your local files against the S3 bucket and only copies files that have changed (by comparing file sizes and checksums).

like image 99
Kris Anderson Avatar answered Sep 26 '22 03:09

Kris Anderson