This week I’m attending a two day course as an intro to Build Forge, followed up by a two day workshop on the use of RAFW. Between the lessons I have tried to create a simple adaptor to Build Forge which does nothing more than call a batch file and return the current date to the Bill of Materials. Not rocket science, but I need to start simple to learn it 🙂
I got the bat file from http://www.tech-recipes.com/rx/956/windows-batch-file-bat-to-get-current-date-in-mmddyyyy-format/ I just edited it a bit, making this the last line
echo Current date: %dd%.%mm%.%yyyy%
Calling a bat file like this might seem kinda stupid, but since adaptors are meant to enable you to call executables using command line, stupid is ok for now. The XML for the adaptor calling the bat file is like this
<?xml version="1.0"?>
<!DOCTYPE PROJECT_INTERFACE SYSTEM "interface.dtd">
<PROJECT_INTERFACE IFTYPE="Source" INSTANCE="7.02">
<template>
<env name="FILEPATH" value="path_to_file_with_ending_slash" />
<env name="FILENAME" value="name_of_bat_file_to_run" />
</template>
<interface name="ByDate">
<run command="command" params="$FILEPATH $FILENAME" server="$BF_SERVER" dir="/" timeout="360"/>
</interface>
<command name="command">
<execute>
$FILEPATH$FILENAME
</execute>
<resultsblock>
<match pattern="^Current date: (.*)">
<bom category="Result" section="CurrentDate">
<field name="currdate" text="$1"/>
</bom>
</match>
</resultsblock>
</command>
<bomformat category="Result" title="Current Date">
<section name="CurrentDate">
<field order="1" name="currdate" title="Date"/>
</section>
</bomformat>
</PROJECT_INTERFACE>
(Using Blogcrowds to escape the XML)
Note that you also need to create an environment in Build Forge containing the two variables in the template-section. The adaptor xml only describes them, it does not instantiates them. So create the environment and refer to it in your project or the step.
I would also recommend playing around with the bomformat-tag, which enables you to format the “Bill Of Material format”, creating headers, sections and fields.