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

amazon-s3, continuous-integration, jenkins

Solution

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).

Problem

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?

Original source

Related problems