Dukes Bank Checkout and Build

From ControlTier

Jump to: navigation, search

Java duke mascot.jpg This is part of the DukesBank portion of the ControlTier Demo

Contents

Overview

In this demo we are going to coordinate the build process for the Dukes Bank application. This example shows the JBossAntBuilder type coordinating a build cycle that includes: source code checkout, build tool invocation and finally build artifact repository staging. The output will be a .ear file that is registered in your ControlTier package repository

Stop-medium.png This demo assumes the Subversion client is installed. You can download a binary distribution from Collabnet

Screencast-icon.png Watch a video of this demo (less than 5:00)

Prerequisites

This demo assumes you have completed:

Prepare the Build Environment Using Deploy Command

The first step before running the actual build cycle is to run the builder's "Deploy" command which will take care of ensuring all the build processes dependencies are in place.

In this demo, dukesBank (which is a builder instance of type JBossAntBuilder), will ensure it has the correct version of the Ant build tool and JBoss.

Workbench shows this in its graphical "Process Flow" view. You can see this visualization for the Deploy command for the "dukesBank" JBossAntBuilder below:

JBossAntBuilder deploy processflow.png

Run the following command to have the dukesBank instance of the JBossAntBuilder download and install it's own dependencies:

ctl -p demo -t JBossAntBuilder -r dukesBank -c Deploy

You should output similar to that shown below:

Start: "Run the deployment cycle, coordinating package installation and configuration." commands: Packages-Install,Configure
begin workflow command (1/2) -> "Packages-Install " ...
.
.
.
Package is VERIFIED
Completed: Installed packages:   jboss-4.0.3SP1.zip[JBossZip],  apache-ant-1.7.0-bin.zip[AntZip]
end workflow command (1/2) -> "Packages-Install "
begin workflow command (2/2) -> "Configure " ...
begin workflow command (1/1) -> "Docs-Generate " ...
end workflow command (1/1) -> "Docs-Generate "
end workflow command (2/2) -> "Configure "
[command.timer: 11.578 sec]
Completed: execution time: 11.578 sec

You'll notice that the JBoss zip is deployed as well. This is because the builder needs to use some JBoss libraries when building the .ear.

Verify Checkout

The next step confirms the source code connection is defined correctly and accessible. Checkout is handled by a standard command called "scmCheckout". This command interfaces with the SCM client tool and is configured with a number of parameters like connection string, module name, and base directory. In this demo, the source repository is hosted on sourceforge.net.

Run the scmCheckout command without any arguments:

ctl -p demo -t JBossAntBuilder -r dukesBank -c scmCheckout

You will see output similar to below:

scmCheckout parameters: {basedir="/home/alexh/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="j2eetutorial14", label="", scmcommand="checkout" }
A    j2eetutorial14/doc
A    j2eetutorial14/doc/WebApp.html
.
.
.
A    j2eetutorial14/examples/saaj/headers/src/HeaderExample.java
A    j2eetutorial14/examples/saaj/headers/build.xml
Checked out revision 1113.
[command.timer.Builder.scmCheckout: 6.791 sec]

See #Troubleshooting if you get a SVN server certificate error.

Build

Run the Build Command

With the preparation and verification steps out of the way you are now ready to demonstrate the full build cycle. The Build command is a workflow that carries out the steps of the build cycle. Workbench shows this in its graphical "Process Flow" view. You can see can see this visualization for the Build command of the "dukesBank" JBossAntBuilder below:

DukesBank-JBossAntBuilder-Build-pview.png

You can see the Build workflow has four commands:

  1. scmCheckout: checkout the source code
  2. setBuildstamp: automatically set a build identifier (in this case using the Subversion revision info)
  3. runBuildscript: invoke the build tool (Ant in this case)
  4. repoImport: upload the build artifacts to the repository

Run the Build command without arguments:

ctl -p demo -t JBossAntBuilder -r dukesBank -c Build 

...with output similar to below:

Start: "Run the build cycle." commands: scmCheckout,setBuildstamp,runBuildScript,repoImport
begin workflow command (1/4) -> "scmCheckout " ...
scmCheckout parameters: {basedir="/home/alexh/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="j2eetutorial14", label="", scmcommand="checkout" }
Checked out revision 1113.
[command.timer.Builder.scmCheckout: 6.932 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/demo/resources/JBossAntBuilder/dukesBank/var/null1948851042.out
Automatically set buildstamp to "trunk.1.2.3.952"
[command.timer.Builder.setBuildstamp: 8.236 sec]
end workflow command (2/4) -> "setBuildstamp "
begin workflow command (3/4) -> "runBuildScript " ...
Buildfile: j2eetutorial14/examples/bank/jboss-build.xml

prepare:
    [mkdir] Created dir: /home/alexh/ctier/demo/elements/build/cruisecontrol-bin-2.7.1/projects/dukesBank/j2eetutorial14/examples/bank/build

compile:
    [javac] Compiling 61 source files to /home/alexh/ctier/demo/elements/build/cruisecontrol-bin-2.7.1/projects/dukesBank/j2eetutorial14/examples/bank/build
    [javac] Note: Some input files use unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.

prepare:

compile:

package-ejb:
    [mkdir] Created dir: /home/alexh/ctier/demo/elements/build/cruisecontrol-bin-2.7.1/projects/dukesBank/j2eetutorial14/examples/bank/jar
      [jar] Building jar: /home/alexh/ctier/demo/elements/build/cruisecontrol-bin-2.7.1/projects/dukesBank/j2eetutorial14/examples/bank/jar/bank-ejb.jar

prepare:

compile:

package-web:
     [copy] Copying 1 file to /home/alexh/ctier/demo/elements/build/cruisecontrol-bin-2.7.1/projects/dukesBank/j2eetutorial14/examples/bank/web
      [war] Building war: /home/alexh/ctier/demo/elements/build/cruisecontrol-bin-2.7.1/projects/dukesBank/j2eetutorial14/examples/bank/jar/web-client.war

prepare:

compile:

package-client:
     [copy] Copying 2 files to /home/alexh/ctier/demo/elements/build/cruisecontrol-bin-2.7.1/projects/dukesBank/j2eetutorial14/examples/bank/build
      [jar] Building jar: /home/alexh/ctier/demo/elements/build/cruisecontrol-bin-2.7.1/projects/dukesBank/j2eetutorial14/examples/bank/jar/app-client.jar

assemble-app:
      [ear] Building ear: /home/alexh/ctier/demo/elements/build/cruisecontrol-bin-2.7.1/projects/dukesBank/j2eetutorial14/examples/bank/jar/JBossDukesBank.ear

BUILD SUCCESSFUL
Total time: 4 seconds
[command.timer.runBuildScript.exec.ant: 5.368 sec]
[command.timer.AntBuilder.runBuildScript: 5.372 sec]
end workflow command (3/4) -> "runBuildScript "
begin workflow command (4/4) -> "repoImport " ...
Created dir: /home/alexh/ctier/ctl/projects/demo/resources/JBossAntBuilder/dukesBank/tmp/Builder-repoImport-20090114174116
Condition: isProcessableWithoutExistingPropfile result: true
opts.propfile set to: autogenerated-builder.properties
Creating new property file: 
/home/alexh/ctier/ctl/projects/demo/resources/JBossAntBuilder/dukesBank/tmp/Builder-repoImport-20090114174116/import-count.properties
processing files in directory: '/home/alexh/ctier/demo/elements/build/cruisecontrol-bin-2.7.1/projects/dukesBank/j2eetutorial14/examples/bank' 
matching: '(JBossDukesBank)(?:-trunk.1.2.3.952)?\.(ear)$' ...
processing matched file: jar/JBossDukesBank.ear
Auto-generated builder properties file created: 
/home/alexh/ctier/demo/elements/build/cruisecontrol-bin-2.7.1/projects/dukesBank/j2eetutorial14/examples/bank/jar/autogenerated-builder.properties...
Copying 1 file to /home/alexh/ctier/demo/elements/build/cruisecontrol-bin-2.7.1/projects/dukesBank/j2eetutorial14/examples/bank/jar
Copying 1 file to /home/alexh/ctier/ctl/projects/demo/modules/Builder/commands
Getting: http://strongbad:8080/jackrabbit/repository/controltier/projects/demo/publish/modules/JBossEar-head.jar
To: /home/alexh/ctier/ctl/var/tmp/downloads/demo/JBossEar-head.jar
Created dir: /home/alexh/ctier/ctl/projects/demo/modules/JBossEar
Expanding: /home/alexh/ctier/ctl/var/tmp/downloads/demo/JBossEar-head.jar into /home/alexh/ctier/ctl/projects/demo/modules/JBossEar
module did not have module.version property: ear
Getting: http://strongbad:8080/jackrabbit/repository/controltier/projects/demo/publish/modules/ear-7.jar
To: /home/alexh/ctier/ctl/var/tmp/downloads/demo/ear-7.jar
module did not have module.version property: ear
Expanding: /home/alexh/ctier/ctl/var/tmp/downloads/demo/ear-7.jar into /home/alexh/ctier/ctl/projects/demo/modules/ear
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/demo/JBossEar/ears/JBossDukesBank-trunk.1.2.3.952.ear...
Uploading to: http://strongbad:8080/jackrabbit/repository/controltier/projects/pkgs/demo/JBossEar/ears/JBossDukesBank-trunk.1.2.3.952.ear
Uploading: JBossDukesBank.ear
Puted 1 file to http://strongbad:8080/jackrabbit/repository/controltier/projects/pkgs/demo/JBossEar/ears/JBossDukesBank-trunk.1.2.3.952.ear
Creating new property file: /home/alexh/ctier/ctl/projects/demo/resources/JBossAntBuilder/dukesBank/tmp/Builder-repoImport-20090114174116/import-list.properties
Deleting: /home/alexh/ctier/ctl/projects/demo/modules/Builder/commands/entity820874211.properties
Updating property file: /home/alexh/ctier/ctl/projects/demo/resources/JBossAntBuilder/dukesBank/tmp/Builder-repoImport-20090114174116/import-count.properties
Current count: 1
Batch request performed successfully.
Current count: 1
[command.timer.Builder.repoImport: 8.137 sec]
end workflow command (4/4) -> "repoImport "
[command.timer: 31.288 sec]
Completed: execution time: 31.288 sec

The output shows a file "JBossDukesBank-trunk.1.2.3.952.ear" uploaded to the WebDAV server.

Query the repository

Use the repoFind command to query the repository to see what JBossEar packages exist:

ctl -p demo -t JBossAntBuilder -r dukesBank -c repoFind -- -packagetype JBossEar

... with results listed like so:

Created dir: /home/alexh/ctier/ctl/projects/demo/resources/JBossAntBuilder/dukesBank/var/sessions
Querying model for matching package objects ...
|
|--(JBossEar) JBossDukesBank-trunk.1.2.3.952.ear
session data saved: /home/alexh/ctier/ctl/projects/demo/resources/JBossAntBuilder/dukesBank/var/sessions/find.session

The output above shows there is currently one JBossEar package. Subsequent builds will result in new versions of the JBossEar package.

You can also check Workbench's "Package Manager" to find the newly uploaded package. Clicking on the object will show its metadata like the screenshot below:

DukesBank-JBossEar-object-view.png

Specifying your own Buildstamp

The first example of "Build" used automatic buildstamp generation. You can also specify the buildstamp via a command line option. The example below uses a date stamp:

 ctl -p demo -t JBossAntBuilder -r dukesBank -c Build -- -buildstamp 20090114

Output:

Start: "Run the build cycle." commands: scmCheckout,setBuildstamp,runBuildScript,repoImport
begin workflow command (1/4) -> "scmCheckout -buildstamp 20090114" ...
scmCheckout parameters: {basedir="/home/alexh/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="j2eetutorial14", label="", scmcommand="checkout" }
Checked out revision 1113.
[command.timer.Builder.scmCheckout: 37.274 sec]
end workflow command (1/4) -> "scmCheckout -buildstamp 20090114"
begin workflow command (2/4) -> "setBuildstamp -buildstamp 20090114" ...
Using provided buildstamp "20090114"
[command.timer.Builder.setBuildstamp: 2.690 sec]
end workflow command (2/4) -> "setBuildstamp -buildstamp 20090114"
begin workflow command (3/4) -> "runBuildScript -buildstamp 20090114" ...
Buildfile: j2eetutorial14/examples/bank/jboss-build.xml

prepare:
    [mkdir] Created dir: /home/alexh/ctier/demo/elements/build/cruisecontrol-bin-2.7.1/projects/dukesBank/j2eetutorial14/examples/bank/build

.
.
.
JBossEar up to date
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-20090114.ear...
Uploading to: http://strongbad:8080/jackrabbit/repository/controltier/projects/pkgs/default/JBossEar/ears/JBossDukesBank-20090114.ear
Uploading: JBossDukesBank.ear
Puted 1 file to http://strongbad:8080/jackrabbit/repository/controltier/projects/pkgs/default/JBossEar/ears/JBossDukesBank-20090114.ear
Creating new property file: 
/home/alexh/ctier/ctl/projects/default/resources/JBossAntBuilder/dukesBank/tmp/Builder-repoImport-20090114183226/import-list.properties
Deleting: /home/alexh/ctier/ctl/projects/default/modules/Builder/commands/entity1229686924.properties
Updating property file: 
/home/alexh/ctier/ctl/projects/default/resources/JBossAntBuilder/dukesBank/tmp/Builder-repoImport-20090114183226/import-count.properties
Current count: 1
Batch request performed successfully.
Current count: 1
[command.timer.Builder.repoImport: 8.579 sec]
end workflow command (4/4) -> "repoImport -buildstamp 20090114"
[command.timer: 54.458 sec]
Completed: execution time: 54.458 sec

The output above shows the another JBossEar package uploaded, this time "JBossDukesBank-20090114.ear".

Of course you can confirm this via repoFind:

ctl -p demo -t JBossAntBuilder -r dukesBank -c repoFind -- -packagetype JBossEar
Created dir: /Users/alexh/ctier/ctl/projects/demo/resources/JBossAntBuilder/dukesBank/var/sessions
Querying model for matching package objects ...
|
|--(JBossEar) JBossDukesBank-20090114.ear
|
|--(JBossEar) JBossDukesBank-trunk.1.2.3.952.ear
session data saved: /Users/alexh/ctier/ctl/projects/demo/resources/JBossAntBuilder/dukesBank/var/sessions/find.session

For example's of common maintenance commands for managing the ControlTier package repository see:

Summary

In this demo we covered:

With the JBoss EAR loaded you can proceed to the next demo: Dukes Bank Provisioning JBoss applications

Troubleshooting

The scmCheckout command could fail if there is an SVN server certificate change. The command fails because scmCheckout is a batch mode command and does not permit interacting with the svn client so it fails:

$ ctl -p demo -t JBossAntBuilder -r dukesBank -c scmCheckout
scmCheckout parameters: {basedir="/home/alexh/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", 
module="src", label="", scmcommand="checkout" }
Error validating server certificate for 'https://moduleforge.svn.sourceforge.net:443':
 - The certificate is not issued by a trusted authority. Use the
   fingerprint to validate the certificate manually!
Certificate information:
 - Hostname: *.svn.sourceforge.net
 - Valid: from Tue, 11 Nov 2008 20:25:27 GMT until Mon, 11 Jan 2010 20:25:27 GMT
 - Issuer: Equifax Secure Certificate Authority, Equifax, US
 - Fingerprint: 04:b2:70:e9:ba:cf:70:fc:e8:8a:22:86:14:13:51:97:1b:6a:de:38
(R)eject, accept (t)emporarily or accept (p)ermanently? svn: OPTIONS of 
'https://moduleforge.svn.sourceforge.net/svnroot/moduleforge/elements/branches/3.2.4/demo/DukesBank/src': 
Server certificate verification failed: issuer is not trusted (https://moduleforge.svn.sourceforge.net)

Command failed: The following error occurred while executing this line:
/home/alexh/ctier/ctl/projects/default/modules/Builder/lib/scm/svn.xml:83: exec returned: 1

To confirm the certificate just run the svn client directly and accept the change by typing "p" at the prompt:

$ svn co https://moduleforge.svn.sourceforge.net/svnroot/moduleforge/elements/branches/3.2.4/demo/DukesBank/src
Error validating server certificate for 'https://moduleforge.svn.sourceforge.net:443':
 - The certificate is not issued by a trusted authority. Use the
   fingerprint to validate the certificate manually!
Certificate information:
 - Hostname: *.svn.sourceforge.net
 - Valid: from Tue, 11 Nov 2008 20:25:27 GMT until Mon, 11 Jan 2010 20:25:27 GMT
 - Issuer: Equifax Secure Certificate Authority, Equifax, US
 - Fingerprint: 04:b2:70:e9:ba:cf:70:fc:e8:8a:22:86:14:13:51:97:1b:6a:de:38
(R)eject, accept (t)emporarily or accept (p)ermanently? p
.
.
.

You don't have to wait for the whole checkout to complete. The main point is to have the svn client cache the cert info.

Now you will be able to run scmCheckout.

Personal tools
Namespaces
Variants
Actions
Navigation
Communication
Development
Toolbox
Print/export