Pergunta

I am using jenkins to continuously build the website front-end code from github repository, package it up into the tar archive and post the it to the S3 bucket. The Jenkins build creates files named like this FrontEnd-122.tgz where 122 is the build number.

I am using the following recipe to deploy the app onto the server:

deploy_version = node['my-app']['build-number']
deploy_from    = "http://mybucket.com/FrontEnd-#{deploy_version}.tgz"

tar_extract "#{deploy_from}" do
  target_dir '/usr/local/site/FrontEnd'
  creates '/usr/local/site/FrontEnd/index.php'
  tar_flags [ '--strip-components 1' ]
end

This all works great, however I have to manually update the node attribute my-app/build-number. Which is fine for QA and production deployments.

What I would like to do is to have a snapshot deployment VM, where I the latest code gets deployed, for further testing with selenium and friends. However, to do that I need to have a way for the above cookbook to figure out what is the latest build number is and deploy from there. Do you have any suggestions?

Foi útil?

Solução

Tricky one because you need a mechanism for chef to determine the latest revision stored in S3.

Presumably you store the code in a revision control system like subversion or git? Would it be feasible to use the chef deploy resource instead? Let chef pull the website code from your trunk or master branch, for testing purposes.

Another option would be to use a binary repository manager that understands the concept of "Snapshots". Take a look at products like Nexus, Artifactory and Archiva. You could then use S3 for both backup and a distribution area for approved and released copies of your site.

Outras dicas

So, I used the dumb way to solve this issue. Besides putting the versioned archive to the S3 bucket. I also push the same archive using the name like 'FrontEnd-Latest'. Also I modified the cookbooks to use a version parameter. The staging server has version parameter set to 'Latest' and the production server has the parameter set to whatever version is considered to be stable.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top