Simplifying publication to Rational Asset Manager using Ant's macrodef
One of the tasks on my new project (see "Use of rational Asset Manager Ant Tasks") is to publish several types of assets to Rational Asset Manager. The Ant tasks supplied by RAM are fairly straightforward, though can be a little verbose.So I decided to construct a macrodef to allow repeatability and minimise typing errors. This approach worked fine for the "Tools and Automation" type of asset, but it failed failed when I tried it for a "General Documentation" type of asset, at it needed to be supplied with two extra custom attributes, namely Abstract and Agreement Required. At this point I did a bit of digging and found macrodefs provide an element facility to allow you to pass complex structures into the macro.
The resulting macrodef I came up with was this.
<macrodef name
<attribute name="name" /> <attribute name="version" /> <attribute name="type" /> <attribute name="zipfile" /> <attribute name="description" /> <attribute name <element name <sequential> <ram:server id="ramServer" user <ram:modify server="ramServer"> <ram:search name="@{name}" vers <ram:asset> <ra <ra <ra <ra <cu <ram:artifactSet src="@{zipfile}"> <!-- Create artifact references to the artifacts in the .zip file above with the following properties. --> <ram:reference> <ram:description> BUILD_LABEL = ${bu BUILD_URL = <a href='${build.url}' target='_blank' > Build Info SOU BUILD_RESULT_UUID = ${bu BUI </ram:description> <!-- Set the reference kind to "build reference." --> <ra <ram:value> </ram:value> </ram:reference> </ram:artifactSet> <ra <ra </ram:asset> </ram:modify> </sequential> </macrodef>
As you can see I've highlighted the specification and placement of the customAttributes element.
For completeness, here are the basic properties I set which are common to all asset publications. I'm using a jazz build engine which helpfully supplies the properties, buildLabel, repositoryAddress, buildDefinitionId and buildResultUUID as part of the context of the build.
<!-- General properties for Rational Asset Manager --> <property name="ram.url" valu <property name="ram.user.id" valu <property name <property name <property name="build.label" valu <property name="build.url" valu <property name <property name="build.def.id" valu <property name
So here is all I now have to define in my Ant build file when I want to publish a "Tools and Automation" type of asset, which has NO custom attributes.
<publish.to.ram
name="Project Tools" ver type="Tools and Automation" zip sho des <cu </publish.to.ram>
..and here is all I define when I want to publish a "General Documentation" type of asset, which has custom attributes Abstract and Agreement Required.
<publish.to.ramname="Project Documentation" vers type="General Documentation" zipf shor desc <customAttributes> <ram:attribute name <ram:attribute name="Agreement Requ </customAttributes> </publish.to.ram> |