I am getting started on adding continuous integration to an EC2 project using Jenkins. After the build execution I am deploying the build artifacts in the virtual machines.
Now having some problem with the intermediate files I need to maintain in Jenkins. During the deployment execution my glue ant task is running from the workspace/ folder. At this time I need to create several intermediate files that are this particular build specific.
How to maintain this files? I am aware of the Jenkins directory structure. (Jenkins documentation link on this)
Should I create these files under the builds/[BUILD_ID] folder.
However I do not find a way to get the this folders absolute path. (However I can deduct it from WORKSPACE variable which is available in Jenkins) I already checked Jenkins Set Environment Variables.
Jenkins can store artifacts for each build. You can specify the folders that you want to archive. (However, I simply find it easier to copy all of my required artifacts under a single folder. This way, I cam simply specify that one folder and not worry if I am missing anything.)
If you need these files for deployment based upon the build, I would store them as build artifacts in Jenkins. These are stored in
http://$JENKINS_URL/$JOB_NAME/$BUILD_NUMBER/artifact/...where...is the directory structure of your workspace. For example, I tend to build everything in my Java projects undertargetand store my artifacts under thetarget/archivefolder (Makes it easier to save all of your artifacts if they're under a single folder) If I have a filefoo.txtstored as an artifact, it's URL would be:I can use
wgetorcurlto pull down this artifact.You may also decide (if you're using Ant anyway) to zip up or create a tarball of all of your artifacts in one easy to grasp file. That's what I do. Actually, there are usually three files in my
target/archivedirectory:DEPLOYMENT_DIRECTIONS.txtwhich contains deployment directions.deploy.shthat is my actual deployment file.In my
DEPLOYMNET_DIRECTIONS.txtfile are these directions:Inside my
build.xmlis something like this:The
<filterset>replaces the@...@variables with the environment variables from Jenkins itself. Now, myDEPLOYMENT_DIRECTIONS.txtlook like this:You can cut and paste that line from direction #2 right on the server.
A few notes:
curlinstead ofwgetbecausecurl -owill overwrite an existingdeploy.shfile. This way, I don't have to worry thatwgetwill download the newest onedeploy.sh.2on me and someone accidentally runs the olderdeploy.shfrom a previous build.base deploy.shbecause I don't have to worry about paths, and setting the executable bit on thedeploy.shshell script. It's just easier to tell people to usebash deploy.shthan specify thechmod u+x, then do./deploy.sh.Hope this helps.
By the way, this was designed with three different comfort levels of groups:
DEPLOYMENT_DIRECTIONS.txtfile in the build they want to manually deploy.DEPLOYMENT_DIRECTIONS.txtfile. That's pretty simple to do since it's just downloadingdeploy.shand running it.Hope this helps.