Powerbuilder on CuriseControl

Cruise Control is an Automated Continuous Integration server can monitor source code, auto build and deploy. Developed by Thoughtworks and is popular in dotNet world.

Command Line Mode Compile PowerBuilder project

To enable PowerBuilder running on Cruise Control, we have to set up ORCAScript to get latest version from VSS and compile all by command line. Here are my script original copied from sys-con.

;**********************************************************************
; This is the PBORCA file to build the Application SC
;**********************************************************************
start session
;**********************************************************************
; Set up the SCCS Connection Parameters
;**********************************************************************
scc set connect property provider “Microsoft Visual SourceSafe”
scc set connect property userid “guest”
scc set connect property project “~”$/pb~”, RDAAAAAA”
scc set connect property auxproject “\\path_to_vss_server\vss”
scc set connect property localprojpath “C:\work_dir\”
scc set connect property logfile “buildfromsource.log”
scc set connect property logappend false
; This is to delete those *.sr* files.
scc set connect property deletetempfiles true

;**********************************************************************
; Now Connect to the SCCS Provider
;**********************************************************************
scc connect

;**********************************************************************
; Refresh all the objects in all the PBLs in the target of the
; application and regenerate them all
;**********************************************************************

; In case lib list changed.
scc get latest version “test.pbt”

; This will pull all the VSS objects to local in *.sr* single file format. options: “refresh_all outofdate exclude_checkout”
scc set target “test.pbt” refresh_all

; This is doing the actual import.
; Compile error might occur here, but error message
; won’t be displayed on build console.
; Had to do a file merge task in cc.net publisher configuration.

scc refresh target Full
;or INCREMENTAL or MIGRATE

**********************************************************************
; We could build the exe and PBD here, but team lead may prefer do this manually. ;**********************************************************************
;**********************************************************************
; Close the PBORCA Session
;**********************************************************************
end session

cc.net publishers

<publishers>
<merge>
<files>
<file>c:\work_dir\test\*.log</file>
</files>
</merge>
<xmllogger />
<statistics />
</publishers>

Obsolete objects in pbl

Delete *.pbl in the outer build.xml is necessary. I tried delete file in orcascript, it locked the process.

(0027): Error C0193: One or more of the files in your library list could not be opened for write.

It might because the session hasn’t finished yet, so this deleted file is still being locked?

The worst part is, deleting pbl in build file caused the following compile work failed! The pure compile without delete task works OK. It seems the compile part needs run twice. (You can use PowerGen if your budget is not tight) First one to import, second one to do the real compile? So my final build file looks like this:

<project name=”build-test” default=”build-pbd”
basedir=”./”>
<target name=”build-pbd” depends=”delete-pbl”>

<exec executable=”orcascr105″ failonerror=”false” >
<arg line=”build_test.orca” />
</exec>

<exec executable=”orcascr105″ failonerror=”true” >
<arg line=”build_test.orca” />
</exec>
</target>

<target name=”delete-pbl”>
<delete>
<fileset dir=”.” includes=”**/*.pbl” excludes=”**/*proxies.pbl”/>
</delete>

</target>
</project>

Note: watch out you pbg file, make sure the path are matched, otherwise the re-generate pbl will fail. We should delete pbls before do any build.

Differences between cc.net and cc

Then we can download CruiseControl and configure a powerBuilder project within it. Following the instruction. Like step 1a said, we have to manually copy all the pbl into work folder at first.

After done the config.xml, I found the CruiseControl server has some problem on start-up, I didn’t want to spent too much time on it so I downloaded CruiseControl.net and installed it.

Make Ant work with CC/CC.net

I have a feeling that cc.net is faster than cc, and also more user friendly, except the configuration doesn’t support ant task very well. I have to setup ant task as an external exec one. Here is the ant part in my project settings. (We actually switched to NAnt very soon after this, the log-viewer is better.)

<tasks>
<exec>
<executable>C:\App\ant_165\bin\ant.bat</executable>
<baseDirectory>C:\TEMP\gain_cc</baseDirectory>
<buildArgs>-buildfile=build-gain_rc.xml</buildArgs>
</exec>
</tasks>

Everything else looks same. The cc tray application is very handy, I like it.

The exit code problem bugged me for a long time. Even ant exit with 1 which means failure, cc.net always report successful. Then I found this page, by add the following line to the end of the ant.bat file, problem went away.

  • exit %ERRORLEVEL%

NAnt

CC.net supports NAnt output directly. NAnt is preferred for CC.net. Add this task in ccnet.config:

<tasks>
<nant>
<buildArgs>-D:clean.build=true</buildArgs>
<buildFile>C:\Work_Dir\your_project\default.build</buildFile>
<buildTimeoutSeconds>1200</buildTimeoutSeconds>
</nant>
</tasks>

Pass ORCA Command within CruiseControl

To pass the orca command around, I need to add this line in the build.xml in root work_dir folder.

<project name=”build-rc” default=”build-pbd” basedir=”./”>
<target name=”build-pbd”>

<!– pbl will be regenerated in orca script. pb’s scc refresh can also delete obsolete objects! –>
<delete file=”*.pbl” />

<exec executable=”orcascr105″ output=”orca_compile_output.txt” failonerror=”true”>
<arg line=”build_gain_rc.orca” />
</exec>
</target>
</project>

You may want to copy the folder “C:\Program Files\Microsoft Visual Studio\VSS\win32″ up to VSS server folder.

failonerror=”true” can link orcascript’s return code to build process.

Don’t use output parameter in orca executable syntax, otherwise the web dashboard won’t see the error log.

What’s Next

A little bit set up in cc tray, now we get a nice source code monitor to our SourceSafe!

In Powerbuilder 11, we will compile powerbuilder component to dotNet assembly. So we should hook up new PowerBuilder project to NUnit, NCover, …. ?

Advertisements

One thought on “Powerbuilder on CuriseControl

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s