Some time back there was a popular post on blue-green deployment - when you deploy your app - it deploys to a "standby" copy of it - and when ready - you flip over to it (this gives zero down time - even if your app needs time to warm up, and lets you warm up app caches, inspect things, test things etc).
This has now been made even easier thanks to Fabians bg-plugin for the bees command line.
Summary on setup:
Set up 2 apps: app1, and app2 - these will act as your active/standby app pair (either of them could be production at any time, so name them sensibly), then:
bees plugin:install com.cloudbees.sdk.plugins:bg-plugin
bees app:bg:config -n yourRealAppName -a1 app1 -a2 app2 -pal www.some-url-you-own.com
To deploy:
bees app:bg:deploy -n yourRealAppName appArchive.zip/war
It then will deploy that app to the "standby" app. To flip it - once it is ready:
bees app:bg:switch -n yourRealAppName
If it is all HORRIBLY WRONG and people are screaming at you - run the above again - and it is back where you started!
Finally, you can stop the "standby" app once you are happy the cut over went smooth, to save money:
bees app:bg:stop -n yourRealAppName
(it will start up the standby environment next time you deploy to it).
Automating with Jenkins
You can have a job that always deploys to the standby, warms it up, maybe validates it, before cutting over automatically (and then shutting down the standby to save money).
With a freestyle job this is quite simple, the SDK can be scripted like this:
Also note you can do what you want in the "warm up" section - you may do some additional smoke tests - and if it fails - fail the build - the production version won't change! Take this and remove the bits you don't want or add more to it.
See here for a gist of the script .