Dukes Bank Build and Provisioning JBoss applications
From ControlTier
This is part of the DukesBank portion of the ControlTier Demo
Contents |
Overview
In this demo we are going to make a minor source code change to Dukes Bank and then run an end-to-end automated process that begins with source code checkout and continues all the way to the running Dukes Bank site. This example shows several collaborating ControlTier types that work together to unify the build and deploy cycle.
The examples in this demo will introduce the "Updater" type, one of the ControlTier standard types that coordinates a unified build and deployment process. During the demo we will run workflow commands that support this end-to-end process.
Watch a video of this demo (less than 5:00)
Prerequisites
This demo assumes you have completed:
Preparation
Before getting started confirm all the necessary objects are deployed to CTL.
Run the ctl-project command:
$ ctl-project -p demo -a install "Install" command running for resource: (Site) developmentDukesBank "Install" command running for resource: (Updater) developmentDukesBank "Install" command running for resource: (JBossAntBuilder) dukesBank "Install" command running for resource: (HsqldbRdbExportBuilder) dukesBank "Install" command running for resource: (JBossServer) developmentDukesBank "Install" command running for resource: (HsqldbRdb) developmentDukesBank . . .
Make a change to the Dukes Bank source
For illustrative purposes, we are going to make a minor change to welcome message that you see after you login to Dukes Bank.
Edit the welcome and farewell messages in the WebMessages.properties file of the Dukes Bank source code.
$ vi $CTIER_ROOT/demo/elements/build/cruisecontrol-bin-2.7.1/projects/dukesBank/j2eetutorial14/examples/bank/web/WebMessages.properties . . . Welcome=Welcome to Uncle Sam's Bank. Farewell=Thank you for banking with Uncle Sam's Bank. . .
In a live environment we would be committing this change, but to keep the demo simple we are just making the change on the local machine. The builder used in these Dukes Bank demos is configured to build from the local source directory and the scmCheckout command will not overwrite your changes with files from the remote subversion repository.
Review the process flow and current package list
With the preparation steps out of the way you are now ready to demonstrate the full build and deploy cycle. The "BuildAndUpdate" command is a workflow that carries out each of the steps for the end to end process. Workbench shows this in its graphical "Process Flow" view. You can see can see this visualization for the "developmentDukesBank" Updater below:
The process flow view shows that BuildAndUpdate actually is composed of two commands:
- Build: This interfaces all the Builders (in this case just JBossAntBuilder) and invokes their "Build" command.
- Update: This too is a workflow that calls:
- Change-Dependencies: This reconfigures all the Services to use the artifacts from the Build step
- Deploy: This invokes the "Deploy" command across the Site objects
If you look in the Package Manager tool in Workbench, you'll see the two .ear packages from the previous demos (and see that JBossDukesBank-20090114.ear is currently deployed):
You can also look at the dependency tree in the site list to see that the JBossDukesBank-20090114.ear package is the one currently being used:
Run the BuildAndUpdate command
Now run the BuildAndUpdate command specifying a custom buildstamp (for the purpose of the demo we're arbitrarily calling this build "2009123-demo")
ctl -p demo -t Updater -r developmentDukesBank -c BuildAndUpdate -- -buildstamp 20090123-demo
You will see output like so:
Start: "Run the coordinated end-to-end the build and deployment processes across the configured Builders and Sites." commands: Build,Update
begin workflow command (1/2) -> "Build -buildstamp 20090123-demo" ...
Dispatching command 'Build' to objects: dukesBank[JBossAntBuilder] ...
starting: dukesBank[JBossAntBuilder]->Build ...
Start: "Run the build cycle." commands: scmCheckout,setBuildstamp,runBuildScript,repoImport
begin workflow command (1/4) -> "scmCheckout -buildstamp 20090123-demo" ...
scmCheckout parameters: {basedir="/home/demo/ctier/demo/elements/build/cruisecontrol-bin-2.7.1/projects/dukesBank", connection="https://moduleforge.svn.sourceforge.net/svnroot/moduleforge/elements/branches/3.2.4/demo/DukesBank/src", module="", label="", scmcommand="checkout" }
.
.
.
Checked out revision 1135.
[command.timer.Builder.scmCheckout: 7.574 sec]
end workflow command (1/4) -> "scmCheckout "
begin workflow command (2/4) -> "setBuildstamp " ...
Checking "https://moduleforge.svn.sourceforge.net/svnroot/moduleforge/elements/branches/3.2.4/demo/DukesBank/src" for the last changed revision ...
Deleting: /home/alexh/ctier/ctl/projects/default/resources/JBossAntBuilder/dukesBank/var/null1723088645.out
Using provided buildstamp "20090123-demo"
[command.timer.Builder.setBuildstamp: 3.006 sec]
end workflow command (2/4) -> "setBuildstamp -buildstamp 20090123-demo"
begin workflow command (3/4) -> "runBuildScript -buildstamp 20090123-demo" ...
Buildfile: j2eetutorial14/examples/bank/jboss-build.xml
prepare:
.
.
.
uploading file: /home/alexh/ctier/demo/elements/build/cruisecontrol-bin-2.7.1/projects/dukesBank/j2eetutorial14/examples/bank/jar/JBossDukesBank.ear to:
http://strongbad:8080/jackrabbit/repository/controltier/projects/pkgs/default/JBossEar/ears/JBossDukesBank-20090123-demo.ear...
Uploading to: http://strongbad:8080/jackrabbit/repository/controltier/projects/pkgs/default/JBossEar/ears/JBossDukesBank-20090123-demo.ear
Uploading: JBossDukesBank.ear
Puted 1 file to http://strongbad:8080/jackrabbit/repository/controltier/projects/pkgs/default/JBossEar/ears/JBossDukesBank-20090123-demo.ear
Creating new property file: /home/alexh/ctier/ctl/projects/default/resources/JBossAntBuilder/dukesBank/tmp/Builder-repoImport-20090114230501/import-list.properties
Package "JBossDukesBank-20090123-demo.ear (JBossEar)" already registered. Updating object info.
Deleting: /home/alexh/ctier/ctl/projects/default/modules/Builder/commands/entity1092114538.properties
Updating property file: /home/alexh/ctier/ctl/projects/default/resources/JBossAntBuilder/dukesBank/tmp/Builder-repoImport-20090114230501/import-count.properties
Current count: 1
Batch request performed successfully.
Current count: 1
[command.timer.Builder.repoImport: 8.281 sec]
end workflow command (4/4) -> "repoImport "
[command.timer: 28.097 sec]
Completed: execution time: 28.097 sec
end workflow command (1/2) -> "Build "
begin workflow command (2/2) -> "Update " ...
Start: "Changes package dependencies and runs the coordinated deployment cycle across the configured Sites." commands: Change-Dependencies,Deploy
begin workflow command (1/2) -> "Change-Dependencies -resourcename .* -resourcetype [^\.]*" ...
Start: "Query model and switch package dependencies to the specified version or buildstamp.." Changing to package dependencies with buildstamp "20090114" ...
begin workflow command (1/1) -> "runChangeDependencies -dispatch -buildstamp 20090123-demo -version 20090123-demo -resourcename .* -resourcetype [^\.]* " ...
Request succeeded.
end workflow command (1/1) -> "runChangeDependencies -dispatch -buildstamp 20090123-demo -version 20090123-demo -resourcename .* -resourcetype [^\.]* "
[command.timer.default.Mediator.developmentDukesBank.Change-Dependencies: 6.693 sec]
Completed: Dependencies changed. execution time: 6.693 sec
end workflow command (1/2) -> "Change-Dependencies -resourcename .* -resourcetype [^\.]*"
begin workflow command (2/2) -> "Deploy -resourcename .* -resourcetype [^\.]*" ...
Dispatching command 'Deploy' to objects: developmentDukesBank[Site] ...
starting: developmentDukesBank[Site]->Deploy ...
Dispatching command 'Deploy' to objects: developmentDukesBank[HsqldbRdb], developmentDukesBank[JBossServer] ...
.
.
.
Start: "Install the configured package dependencies for the deployment." Beginning installation for packages: hsqldb_1_8_0_10.zip[HsqldbZip], db1-00000000.0.zip[HsqldbRdbDmp] ...
.
.
.
Start: "Install the configured package dependencies for the deployment." Beginning installation for packages: jboss-4.0.3SP1.zip[JBossZip], JBossDukesBank-20090123-demo.ear[JBossEar] ...
.
.
.
begin workflow command (4/4) -> "Start " ...
begin workflow command (1/1) -> "assertServiceIsUp " ...
Running handler command: startServiceWrapper
Workflow beginning. commands: startService,waitforStartEvent
begin workflow command (1/2) -> "startService " ...
Moving 1 file to /home/alexh/ctier/demo/elements/development/dukesbank/jboss-4.0.3SP1/server/default/log
end workflow command (1/2) -> "startService "
begin workflow command (2/2) -> "waitforStartEvent " ...
end workflow command (2/2) -> "waitforStartEvent "
[command.timer: 28.097 sec]
Workflow completed. execution time: 28.097 sec
end workflow command (1/1) -> "assertServiceIsUp "
end workflow command (4/4) -> "Start "
end workflow command (2/2) -> "Deploy -resourcename .* -resourcetype [^\.]*"
[command.timer.default.Mediator.developmentDukesBank.Update: 1:36.559 sec]
Completed: execution time: 1:36.559 sec
end workflow command (2/2) -> "Update "
[command.timer.default.Updater.developmentDukesBank.BuildAndUpdate: 2:06.825 sec]
Note that in a live development scenario where we were checking our changes into a source repository, you could run this command without specifying a build stamp. This would cause the builder to checkout from the head of the trunk and the buildstamp would be automatically generated using the latest subversion revision info. Since we aren't checking these changes in the subversion info would be meaningless, so we specified a custom buildstamp.
View the new package and the dependency changes in Workbench
Once the command has completed executing, you can refresh the package list and you'll see the new package listed (and that it is currently in use):
You can also look at the dependency tree in the site list and see that the new package is the one currently being used:
Go to the Dukes Bank website and view the change
You can now view the running Dukes Bank website. Go to the instructions on Accessing the Dukes Bank Website for more information.
(tada!)
Summary
In this Demo we covered:
- Using an Updater to tie together the both the build and deploy cycles into one end-to-end process
- Running the BuildAndUpdate command to both build and deploy a release of Dukes Bank