It's all about the answers!

Ask a question

Can't understand how to run build


Danial Utri (61) | asked Feb 13 '10, 5:59 a.m.
Hello!

I can't understand how to do incremental build (every hour for example) or just simple build via Rational Team Concern Jazz Express-C.

1. Visual Studio 2008 with Jazz client on WinXP64bit.

2. RTC installed on Suse 10 Server. Database running on DB2 Express-C 9.7

3. I want run build on Windows machine (Windows Server 2003), cause project is .NET framework.

Thanks. :D

5 answers



permanent link
Anthony Kesterton (7.5k7180136) | answered Feb 13 '10, 7:18 a.m.
JAZZ DEVELOPER
Hello!

I can't understand how to do incremental build (every hour for example) or just simple build via Rational Team Concern Jazz Express-C.

1. Visual Studio 2008 with Jazz client on WinXP64bit.

2. RTC installed on Suse 10 Server. Database running on DB2 Express-C 9.7

3. I want run build on Windows machine (Windows Server 2003), cause project is .NET framework.

Thanks. :D


Hi

There are a few things you need to do:

1) Create a build for your code. Use the commandline build capabilities in Visual Studio.
2) Use the Ant tasks to report back info to the RTC Build results
3) Set up the build in RTC so it calls your build script.

The Help system in RTC tells you more about 2) and 3). I recall Jean-Michel created an article or blog entry on Visual Studio builds - it should be here on jazz.net.

anthony

permanent link
Jose Miguel Ordax Cassa (2.4k4126100) | answered Feb 13 '10, 7:23 a.m.
On 2/13/2010 12:08 PM, Danny wrote:
Hello!

I can't understand how to do incremental build (every hour for
example) or just simple build via Rational Team Concern Jazz
Express-C.

1. Visual Studio 2008 with Jazz client on WinXP64bit.

2. RTC installed on Suse 10 Server. Database running on DB2 Express-C
9.7

3. I want run build on Windows machine (Windows Server 2003), cause
project is .NET framework.

Thanks. :D


Do you have any specific problem? Or just a generic question... if your
case is the last, try taking a look to this chapter of RTC Tutorial:

http://publib.boulder.ibm.com/infocenter/rtc/v2r0m0/index.jsp?topic=/com.ibm.team.concert.tutorial.doc/topics/tut_rtc_build.html

Hope it helps,

Chemi.

permanent link
Sudhakar Frederick (80113631) | answered Feb 14 '10, 12:19 a.m.
JAZZ DEVELOPER
Hi

Don't think attachments will make it to the forum so I'm pasting the content of a short HOWTO I wrote that describes on one way to setup VS builds with RTC that uses https://jazz.net/wiki/bin/view/Main/BuildExamples as a starting point and as a template for the example:

HOWTO-VisualStudioBuildwithBatchFile.txt

This example demonstrates how to setup a very simple Jazz-based Microsoft Visual Studio build.

The buildtoolkit tasks are written in java as Ant tasks. This means in order to execute the tasks, your build machine will need to have a java VM available.

You will see how to:

* Create a build definition and build engine
* Create a batch file that invokes msbuild/devenv on a Visual Studio Solution, including Setup and Deployment projects
* Use the buildtoolkit tasks from the batch file for progress monitoring, artifact/file publishing
* Labelling the build with the Visual Studio Solution's AssemblyVersion for easy build tracking once the build results are deployed
* Run the Jazz Build Engine
* Request a build, including changing properties on demand to invoke different target/build/configuration builds
* View the build result

Prerequisites

* You have an existing Visual Studio solution in Jazz SCM that builds cleanly. The example uses some parts of http://msdn.microsoft.com/en-us/library/ms404859.aspx to create a sample Visual Studio Solution.
* You've installed the Team Concert client for Visual Studio and the Team Concert Eclipse client (required to create/manage the build definitions and engine)
* You've installed the Build System Toolkit (on your machine or another build machine)
* From your Team Concert clients, you are able to login to a Jazz Team Server where you are a member of an existing project and team area
* The build batch file will need access to a Java VM and Ant. For this example, you can use the ones that are part of the Team Concert client. In a real setup, you'll need them installed on your build machine.
* The team area has a user "build" with password "build" that will be used to run the build engine

Setup

* Start the Team Concert Eclipse client. Login and connect to your project area
* Go to the Team Artifacts view, expand the project area
* Right-click the Builds node, New Build Definition
* Select the project/team area to associate with the build
* Click Next
* Type an ID for the build definition, such as "vsbuild" (without the quotes)
* Select the "Command Line - Jazz Build Engine" template
* Click Next
* Select "Jazz Source Control"
* Click Finish
* The build definition editor will open
* On the General page, in the Supporting Build Engines section, click Create Engine, type an engine ID such as "vsbuildengine1"
* On the Jazz Source Control page, in the Workspace field click the Create button and create a workspace "VS Build Workspace" flowing with the stream your Visual Studio Solution is developed in and assigning the "build" user as the workspace owner.
* On the Jazz Source Control page, in the Load directory field enter "c:\vsbuild" without the quotes.
* On the Command Line page, in the Command field, enter the command "cmd /c build.bat" without the quotes.
* On the Command Line page, in the Arguments field, enter "${repositoryAddress} ${buildResultUUID} ${projectorsetup} ${target} ${config}" without the quotes
* On the Command Line page, in the Working directory field, enter the directory containing the Visual Studio Solution to be built
* On the properties page add the following properties:
    Name: config
    Value: Release

    Name: projectorsetup
    Value: project

    Name: target
    Value: Build


* Save the definition
* You've just created a Jazz build definition for a command line build
* Leave the definition editor open, we'll come back to it later

Creating the batch file to invoke msbuild
* In the same directory as your Visual Studio Solution create a file called "build.bat" with the following content:

@echo off
setlocal
echo %1 %2 %3 %4 %5
rem Set the path to pickup the ant launcher from the Jazz build toolkit
set ANT_HOME=
set CLASSPATH=C:\IBM\TeamConcertBuild\buildsystem\buildengine\eclipse\plugins\org.apache.ant_1.7.0.v200803061910\lib\ant-launcher.jar
set ANT_LAUNCHER=org.apache.tools.ant.launch.Launcher
set JAZZ_TOOLKIT=C:\IBM\TeamConcertBuild\buildsystem\buildtoolkit

rem set the VS target and build configuration
set target=%4
set config=%5

rem extract the AssemblyVersion value to use as the build label
rem change HelloWorldCS\Properties\AssemblyInfo.cs according to your requirements
FOR /F "usebackq tokens=2 delims=)(" %%i in (`findstr /c:"AssemblyVersion" HelloWorldCS\Properties\AssemblyInfo.cs`) do set versionlabel=%%i
rem remove the quotes from the extracted value
set versionlabel=%versionlabel:"=%
@echo %versionlabel%

rem notify that we're starting the build
java -cp %CLASSPATH% %ANT_LAUNCHER% -f jazzbuild.xml -lib %JAZZ_TOOLKIT% -DrepositoryAddress=%1 -DbuildResultUUID=%2 -DactivityLabel="Building %3 %4 %5"

rem setup the envrionment for VS
call "C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat" x86

rem normal solutons/projects can be built with msbuild
rem Setup and deployment projects must be built with devenv
if %3==project goto buildproject
if %3==setup goto buildsetup

:buildproject
msbuild "HelloWorldTest.sln" /t:%target% /p:Configuration=%config%
goto end

:buildsetup
devenv HelloWorldTest.sln /Build %config% /Project HelloWorldTestInstaller
goto end

:end
set BUILD_STATUS=%ERRORLEVEL%

rem notify that build is finished and now publishing results
java -cp %CLASSPATH% %ANT_LAUNCHER% publishActivity -f jazzbuild.xml -lib %JAZZ_TOOLKIT% -DrepositoryAddress=%1 -DbuildResultUUID=%2 -DactivityLabel=Publishing -Dversionlabel=%versionlabel%

exit %BUILD_STATUS%
endlocal

Note that you will need to modify the following in the above batch file to suit your particular configuration:
    CLASSPATH
    
    JAZZ_TOOLKIT
    HelloWorldCS\Properties\AssemblyInfo.cs
    C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat
    HelloWorldTest.sln
    HelloWorldTestInstaller


Invoking Jazz buildtoolkit Ant tasks in a batch file build

The buildtoolkit contains several Ant tasks that are helpful in creating a richer build experience in Team Concert. For example, you can enable fine-grained progress monitoring by using the startBuildActivity task, and publish build logs and artifacts using the logPublisher and artifactLinkPublisher tasks. A buildtoolkit Ant task reference can be found in the Team Concert help.

Your Visual Studio builds can take advantage of these tasks by adding targets to the batch file that invoke Ant. We'll demonstrate calling the startBuildActivity, a number of publisher tasks, including changing the build label to a custom label (versionLabel in the build.bat) from the batch file.

* Create a file named jazzbuild.xml in the same directory as your build.bat. Add these contents to jazzbuild.xml:
	


<?xml version="1.0" encoding="utf-8"?>
<project name="jazz build targets" default="startActivity">
<property name="userId" value="build"/>
<property name="password" value="build"/>


<import file="C:\IBM\TeamConcertBuild\buildsystem\buildtoolkit\BuildToolkitTaskDefs.xml"/>
<target name="startActivity">
<echo message="Hello, world"/>
<startBuildActivity repositoryAddress="${repositoryAddress}"
userId="${userId}"
password="${password}"
activityIdProperty="buildactivityId"
label="${activityLabel}"
autoComplete="true"
verbose="true"
buildResultUUID="${buildResultUUID}" />
</target>

<target name="publishActivity">
<tstamp/>
<startBuildActivity
buildResultUUID="${buildResultUUID}"
label="${activityLabel}"
autoComplete="true"
repositoryAddress="${repositoryAddress}"
userId="${userId}"
password="${password}"/>
<artifactLinkPublisher repositoryAddress="${repositoryAddress}"
userId="${userId}"
password="${password}"
buildResultUUID="${buildResultUUID}"
url="file:///c:/helloworld/HelloWorldTest/HelloWorldTestInstaller/Release/HelloWorldTestInstaller.msi"
localFilePath="HelloWorldTestInstaller/Release/HelloWorldTestInstaller.msi"
label="a download link"/>
<buildResultPublisher repositoryAddress="${repositoryAddress}"
userId="${userId}"
password="${password}"
buildResultUUID="${buildResultUUID}"
label="${versionlabel}" />
<linkPublisher repositoryAddress="${repositoryAddress}"
userId="${userId}"
password="${password}"
buildResultUUID="${buildResultUUID}"
url="http://www.ibm.com"
label="external link" />
</target>



</project>



Starting the build engine

Before you can run builds, you must start the Jazz Build Engine. If you don't start the build engine, your build requests will just sit forever in the build queue. Typically, the build engine runs on a dedicated remote build machine. However, for this example, you can run it on your local machine.

* Open a command prompt or shell
* cd to installdir/buildsystem/buildengine/eclipse
* jbe -repository address -userId build -pass build -engineId vsbuildengine1 -sleeptime 1

Notice how the -engineId argument matches the build engine ID created during the setup.

The build engine should have printed a message like
"Waiting for request..."


Running the build

Now that the build engine is ready to process requests, you can request a build in the Team Concert UI. Or setup a schedule for CI.

* In the definition editor header, click the Request Build button
* In the Request Build dialog, click Submit
* The Builds view will be automatically shown at the bottom of the Team Concert window. You should see your build there. You can refresh the Builds view to track progress of the build.
* Once the build is completed, double-click your build. The build result editor will open.
* In the Contribution Summary section, you should see a link for "1 log". Clicking the link takes you to the Logs page.
* Double-click the log to open it and examine the output of the build command
* There will be an Activities page where you can see the "compiling..." and "publishing..." activities that were created by invoking the corresponding targets from the batchfile
* There will be a "Downloads" page with a URL and a file download available
* There will be an External Links page with an external link URL
* You can use this pattern to add other buildtoolkit tasks to your batchfile

Notes
Hopefully, you were able to follow this example to get the sample build running. This is a quick way to get a Jazz-based build up and running for your team. You'll get build progress monitoring, events, and result viewing for very little setup cost. A few additional notes on the above:

* You can change which target/solution/configuration is built by changing the value of the corresponding property when requesting the build
* Note that "Running the build" section can be performed from the Visual Studio client or even the Web
* Passing the build definition properties in the command line to the ant-launcher call seems a bit unwieldy. The alternative is to turn this inside out ie. use a proper Jazz Ant build and invoke msbuild/devenv as an Ant Exec task; this would make using the properties easier but I didn't have the time to work out how to make sure the environment gets properly set using vcvars.


Communicating values from Ant back to the calling script

In many cases, you only need to pass values to the Ant task, as shown in the example above. Sometimes, however, you will need to get values produced by the task from Ant back into your calling script. One way to do this is to store the values into properties in Ant, and write the properties to a file. Then, the calling script can parse the properties file and get the values. If parsing a properties file is not possible from the calling environment, then some of the task functionality will not be available to your build.

Example of creating a properties file containing the "activityId" value output from Ant:

<project name="jazz build targets">

<target name="startActivity">
<fail message="Missing repositoryAddress" unless="repositoryAddress"/>
<fail message="Missing buildResultUUID" unless="buildResultUUID"/>
<fail message="Missing activityLabel" unless="activityLabel"/>

<!-- Replace ADMIN with your real credentials. -->
<startBuildActivity
buildResultUUID="${buildResultUUID}"
label="${activityLabel}"
activityIdProperty="activityId"
autoComplete="true"
repositoryAddress="${repositoryAddress}"
userId="ADMIN"
password="ADMIN"/>

<propertyfile file="my.properties">
<entry key="activityId" value="${activityId}"/>
</propertyfile>

</target>

<taskdef name="startBuildActivity"
classname="com.ibm.team.build.ant.task.StartBuildActivityTask" />

</project>


After your script invokes Ant, there will be a "my.properties" file that your script can parse and get the value of the activityId.


HTH
Regards
Freddy

permanent link
Danial Utri (61) | answered Feb 23 '10, 10:24 a.m.
sudhakarf big thanks! Your guide succefull help me to configure my build server! Thank you! Thank you!

permanent link
Eitan Shomrai (9154) | answered Jan 24 '12, 10:49 a.m.
How do You suggest to run a step/script before/after the build in the above setup?
Thanks

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.