Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I publish static web resources to Amazon S3 using Hudson/Jenkins and Maven?

I'd like to be able to deploy static web resources (jpgs, css, that sort of thing) to Amazon S3, as they won't be being served by the same server as my main webapp.

I use Jenkins (FKA Hudson) and Maven to build a Java webapp .WAR file and then upload it to a Tomcat instance using the Jenkins "Deploy to container" plugin.

I really want the static assets to be deployed as part of the main build process, but I've no idea the best way to get them to S3. I've seen Hudson/Jenkins plugins that copy artifacts, but that would only be my .WAR file and not the files inside the project.

Any ideas on a 'nice' way to do this? Should I be doing this with a Maven plugin instead of a Hudson/Jenkins one?

like image 979
Deejay Avatar asked Mar 23 '11 15:03

Deejay


2 Answers

This is how I do it: Use an external program, such as s3cmd to do the job. You would simply specify a shell script build step like this

#!/bin/sh

s3cmd --guess-mime-type -P sync $WORKSPACE/src/main/resources s3://your-bucket-name/some/path

You can probably integrate this in your pom.xml and call it from there (so this part of your deployment process is under version control).

like image 61
peritus Avatar answered Sep 23 '22 01:09

peritus


Turned out I didn't need to do this. We were always planning on using CloudFront for distribution, and recently AWS have allowed you to specify a 'custom origin' for CloudFront distributions. This means that static assets can be deployed along with the rest of the .war contents, and then a CloudFront distribution pointed at that application.

like image 31
Deejay Avatar answered Sep 23 '22 01:09

Deejay