It's all about the answers!

Ask a question

RAM customer ANT library download search


Chris Devine (612) | asked Jul 23 '10, 2:41 a.m.
Hello,

We have a schema where a parent asset represents a release and it has many related assets which are components of the system for a given release.

Using the RAM custom ANT library I'd like to be able to download the latest version of a component asset by specifying the parent asset GUID (or better still by name and version) and also the name of a related component asset. I've looked through the RAM ANT APIs and this doesn't seem to be possible currently. The search element of the download task doesn't seem to give me a way to specify the relationship.

Should I write my own ANT task to perform this specialized query and return a GUID that I could then use in the download task?

18 answers



permanent link
Rich Kulp (3.6k38) | answered Jul 23 '10, 9:59 a.m.
FORUM MODERATOR / JAZZ DEVELOPER
Hi,

In the main asset put a "depends on" related asset to the other
subcomponents. Then when you download the main it will have the exact
guid and version of the subcomponents in the main asset related asset
list. You can then explicitly download those assets without requiring a
search.

If you want it to be the "latest" version of each subcomponent, when you
create the relationship to the dependent sub asset, use the "range"
function of the relationship after it is added (the "range" hyper link
on the right side of the relationship) and put the range of versions and
select the "highest" only radio button. RAM will then maintain this
relationship to the highest version automatically.

Use the "Create new version" button when creating a new version of a
subasset. That way RAM knows explicitly that these are versions of the
same asset, and not just another asset that happens to have the same
name. RAM determines highest version by using the GUID of the assets.
All assets with the same GUID are considered to be versions of the same
asset.

Rich

permanent link
Gili Mendel (1.8k56) | answered Jul 23 '10, 11:57 a.m.
JAZZ DEVELOPER
The following snippet will help you see how to navigate through assets/relationships information from ant... You will need to deal with lists/for loops on relationships and artifacts which mean using something like Ant Contrib:



<target name="fetchAssets" description="Download RAM assets" xmlns:ram="antlib:com.ibm.ram.ant">
<!-- create a connection to ram server -->
<ram:server id="ramServer" url="${ramUrl}" username="${userId}" password="${password}" />

<!-- the following provides the ability to use "." to navigate
through RAM object properties ... e.g., specificationAsset.name -->
<ram:propertyHelper/>

<!-- get the release asset... assume guid, version are defined on the build env -->
<ram:asset guid="${asset.release.guid}" version="${asset.release.version}"
server="ramServer" id="releaseAsset" />
<echo message="Relationship Name ${releaseAsset.relationships[3].relationshipTypeName}"/>

<!-- get a Related Asset -->
<ram:asset guid="${releaseAsset.relationships[3].childAssetGUID}"
version="${releaseAsset.relationships[3].childAssetVersion}"
server="ramServer" id="specificationAsset" />
<!-- download an artifact -->
<ram:download destdir="${build.tools}" server="ramServer">
<ram:artifact path="${specificationAsset.artifactsRoot.children[2].path}"
name="${specificationAsset.artifactsRoot.children[2].name}"
asset="specificationAsset" id="artifact"/>
</ram:download>
<echo message="Artifact type ... folder or file: ${artifact.type}"/>
</target>


permanent link
Eric Bordeau (27632) | answered Jul 23 '10, 12:03 p.m.
JAZZ DEVELOPER
And note that you can just remove the version parameter from the ram:asset tag to get the latest version of that asset.

permanent link
Rich Kulp (3.6k38) | answered Jul 23 '10, 2:05 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
On 7/23/2010 12:08 PM, ebordeau wrote:
And note that you can just remove the version parameter from the
ram:asset tag to get the latest version of that asset.

That's true in general. But for this situation if he wants dependency to

latest asset we can do that automatically using the depends on
relationship and range set to highest only. Then not only will it get
the latest that asset itself will be maintained with the relationship to
the latest.

Rich

permanent link
Chris Devine (612) | answered Jul 25 '10, 7:38 p.m.
Thank you very much Richard, Gili and Eric for your help.

permanent link
Chris Devine (612) | answered Jul 26 '10, 1:46 a.m.
Hi Gili,

I've tried using the propertyHelp task but it isn't working for me:

	<target>	


<ram>
<echo>
<ram>
<ram>

<echo>
</target>


The result is:


"C:\installs\apache-ant-1.8.1\bin"\ant -v -lib "C:\buildserver\RAMClient" -file ramClientTest.xml

-Dram.url=http://ramserver:55160/ram.ws -Dram.user.id=userid-Dram.user.passwd=####

-Dasset.release.guid="{647F02A7-3683-B53F-6D70-25B15075D451}" -Dasset.release.version=1.0

Apache Ant version 1.8.1 compiled on April 30 2010
Buildfile: C:\buildserver\RAMClient\ramClientTest.xml
Detected Java version: 1.6 in: C:\Program Files\Java\jdk1.6.0_20\jre
Detected OS: Windows XP
parsing buildfile C:\buildserver\RAMClient\ramClientTest.xml with URI = file:/C:/buildserver/RAMClient/ramClientTest.xml
Project base dir set to: C:\buildserver\RAMClient
Build sequence for target(s) `testHelper' is [testHelper]
Complete build sequence is [testHelper, ]

testHelper:
parsing buildfile jar:file:/C:/buildserver/RAMClient/ramclient-ant.jar!/com/ibm/ram/ant/antlib.xml with URI =

jar:file:/C:/buildserver/RAMClient/ramclient-ant.jar!/com/ibm/ram/ant/antlib.xml from a zip file
parsing buildfile jar:file:/C:/installs/apache-ant-1.8.1/lib/ant.jar!/org/apache/tools/ant/antlib.xml with URI =

jar:file:/C:/installs/apache-ant-1.8.1/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file
[echo] Checking {647F02A7-3683-B53F-6D70-25B15075D451}: 1.0
Creating session for user userid on server http://ramserver:55160/ram.ws
Property "myAsset.name" has not been set
[echo] ${myAsset.name}

BUILD SUCCESSFUL
Total time: 0 seconds
Releasing session for user userid on server http://ramserver:55160/ram.ws

permanent link
Chris Devine (612) | answered Jul 26 '10, 1:53 a.m.
Hi Gili,

I've tried using the propertyHelp task but it isn't working for me:

	<target>	


<ram>
<echo>
<ram>
<ram>

<echo>
</target>



Sorry, this didn't display properly. I've removed the < >


target name="testHelper"
xmlns:ram="antlib:com.ibm.ram.ant"

ram:server id="ramServer" username="${ram.user.id}" password="${ram.user.passwd}" url="${ram.url}"
echo message="Checking ${asset.release.guid}: ${asset.release.version}"
ram:propertyHelper
ram:asset guid="${asset.release.guid}" version="${asset.release.version}" id="myAsset" server="ramServer"

echo message="${myAsset.name}"
target

permanent link
Gili Mendel (1.8k56) | answered Jul 27 '10, 9:42 a.m.
JAZZ DEVELOPER
Are you sure that the connection works.... it is only get executed when you look for an asset and such.

Can you download using this "ramServer" connection?

permanent link
Chris Devine (612) | answered Jul 27 '10, 9:40 p.m.
Are you sure that the connection works.... it is only get executed when you look for an asset and such.

Can you download using this "ramServer" connection?


Yes, the connection appears to be correct and I can download with the connection. I've emailed you the ant script and log4j debug level output. Thanks again for your help.

permanent link
Bilal Ahmed (5611) | answered Oct 03 '11, 3:27 a.m.
Hi,

Is there a way to retrieve the GUID using the search/download task, using the name and version as inputs?


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.