Im trying to update the build quality of a build when the unit tests pass.. I figured how to update the quality of the build using a statement like this...
<Target Name="AfterEndToEndIteration">
<SetBuildProperties
TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
BuildUri="$(BuildUri)"
Quality="Unit Test Passed" />
But i cant seem to isolate the Target when the unit tests SUCCESSFULLY pass.
You should be able to use the TestStatus property to make the target conditional as per Aaron Hallberg's blog post:
http://blogs.msdn.com/aaronhallberg/archive/2008/05/12/orcas-sp1-tfs-build-changes-part-2.aspx
<Target Name="AfterEndToEndIteration" Condition="'$(TestStatus)'=='Succeeded'">
...
</Target>
Related
I'm attempting to implement what I believe should be pretty basic conditioning but am not having any success. I have a target (deploy.DEVELOPMENT) and within this target I call two macros that backup/restore an ini file we using for configuration. The outline is this:
<target name="deploy.DEVELOPMENT" description="Deploy to DEVELOPMENT">
<echo>START: Deploy to ${mode.dev}</echo>
<echo>SOURCE: ${dir.source}</echo>
<macroBackupSourceConfigFile />
<macroUpdateConfigFile
keyDatasource="${setting.devdsn}"
keyServer="${server.devdevweb11}"
keyAppName="${setting.devappname}"
keyApplicationID="${setting.applicationid}"/>
<macroCopyFiles dirSource="${dir.source}" dirTarget="${dir.devdevweb11}"/>
<macroRestoreSourceConfigFile />
<echo>END: Deploy to ${mode.dev}</echo>
</target>
In certain projects an ini file is not required, therefore I would not need to run either of the two macros, just the macroCopyFiles would run. I'd like to just set a property at the top of my ant file to specify whether these macros should be executed.
Any assistance would be greatly appreciated.
Best Regards,
Gary
I think this is what you need... It will perform a check. If file abc.txt is available, abc.present property will exist. Other target will call check-abc and check wether the property abc.present exists. If so, it will execute, else it will not.
<target name="check-abc">
<available file="abc.txt" property="abc.present"/>
</target>
<target name="do-if-abc" depends="check-abc" if="abc.present">
...
</target>
I want to invoke an ant task which should accept multiple test classes for testng and run(not suite xml),
very similar to but comma separated list of test classes. I could not find any clue when I checked the documentation.
Is there a possibility, Please let me know.
This is my ant task to run a single test:
<target name="run-class"
description="run a specific test class. Requires class.name property set to fully-qualified name of class">
<some properties />
<testng classpathref="lib.path"
outputDir="${outputDir}"
workingDir="${workingDir}"
verbose="2"
useDefaultListeners="false"
listeners="${testng.listeners}"
className="${class.name}"
delegateCommandSystemProperties="true"
configFailurePolicy="continue">
<jvm params/>
</testng>
</target>
I would invoke this as : ant run-class -Dclass.name=com.vmware.CreateVM -DParallel=true
I would like to provide another ant task as above which should accept multiple test classes(but not as a suite xml file)
Please refer to TestNG Ant Task documentation and look at the classpath and
classpathref attributes and classfileset element.
I have a target, comprised of several steps, that sometimes fails. All this target does is report to Sonar so if it fails, it's not catastrophic. How do I get the build to succeed even if this specific target fails?
I've tried some combinations of 'condition', 'or', 'true', and 'sequential', but Ant hasn't liked any of them.
Following is what I have more or less:
<target name='sonar'>
<!-- do some stuff -->
<sonar:sonar key='key' version='version'/>
</target>
The only way I can see this could work is using the slightly outdated yet still useful antcontrib extension. Then you can use a try/catch directive and just echo your error.
http://ant-contrib.sourceforge.net/tasks/tasks/trycatch.html
NAnt has two built-in properties, nant.onsuccess and nant.onfailure, for specifying tasks to run on success and failure respectively.
Is there an equivalent in Ant?
I don't think there's an ant equivalent but you could use trycatch (part of ant-contrib)
<trycatch>
<try>
<!-- Your code here -->
<!-- Success message -->
</try>
<catch>
<!-- Fail message -->
</catch>
</trycatch>
Hope this helps
Kev Jackson, gave a neat example of an exec-listener in
his presentation, =
http://people.apache.org/~kevj/ossummit/extending-ant.html,
the sources of the exec-listener are included
You're able to kick off specific tasks depending
on the build result after your build has finished.
<exec-listener onSuccess="true|false">
..
your stuff goes here
..
</exec-listener>
Although I've marked John McG as the answer (as it's what I've gone with), I've also discovered that it's also possible to build similar functionality using BuildListeners.
How would you manually trigger additional team builds from a team build? For example, when we were in CC.Net other builds would trigger if certain builds were successful. The second build could either be projects that use this component or additional, long running test libraries for the same component.
One way you could do it is you could an an AfterEndToEndIteration target to your TFSBuild.proj file that would runs the TfsBuild.exe command line to start you other builds. I'm thinking something like this (though I haven't tested it)
<Target Name="AfterEndToEndIteration">
<GetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
BuildUri="$(BuildUri)"
Condition=" '$(IsDesktopBuild)' != 'true' ">
<Output TaskParameter="Status" PropertyName="Status" />
</GetBuildProperties>
<Exec Condition=" '$(Status)'=='Succeeded' "
Command="TfsBuild.exe start /server:$(TeamFoundationServerUrl) /buildDefinition:"Your Build Definition To Run"" />
</Target>
I've done the same thing Martin suggested on a number of occasions (his blog is beyond helpful, BTW). However, I ended up needing to trigger cascading builds like this (based on some other complicated rules) enough that I created a custom task to do it. Keep your build scripts nice and lean and gives you some more flexibility and encapsulation possibilities.
public override bool Execute()
{
IBuildDefinition[] buildDefinitions = BuildServer.QueryBuildDefinitions(ProjectName);
foreach (IBuildDefinition build in buildDefinitions)
{
if(build.Enabled) //I did a bunch of custom rules here
{
Log.LogMessage(String.Concat("Queuing build: ", build.Name));
BuildServer.QueueBuild(build);
}
}
return true;
}
There's some more good stuff on Aaron Hallberg's blog too:
http://blogs.msdn.com/aaronhallberg/archive/2007/04/24/team-build-object-model-queueing-a-build.aspx