Home | History | Annotate | Download | only in scripts_rss
      1 <?xml version="1.0"?>
      2 
      3 <project name="Watch Feed" default="watchFeed">
      4 
      5 	<taskdef name="WatchFeed" 
      6 	  classname="org.eclipse.releng.services.rss.RSSFeedWatcherTask" 
      7 	  classpath="../feedTools.jar"/>
      8 
      9 	<!-- 1. Define property file -->
     10 	<target name="init">
     11 		<!-- <property file="../properties/feedWatch.emf.properties"/> -->
     12 		<property file="../properties/feedWatch.uml2.properties"/>
     13 	</target>
     14 
     15 	<!-- 2. Watch feed for certain change conditions and respond if necessary -->
     16 	<target name="watchFeed" depends="init" description="Watch feed for certain change conditions and respond if necessary">
     17 		<WatchFeed 
     18 			debug="${debug}" 
     19 			file="${file}" 
     20 			feedURL="${feedURL}"
     21 			feedWatchActions="${feedWatchActions}"
     22 		/>
     23 
     24 		<!--
     25 			Different ways to get at the results of the task include:
     26 			
     27 			feedWatchAction.Result.0       - The result returned from the <exec> task; if set, something bad happened
     28 			feedWatchAction.Error.0        - Details about the error that occurred, if set, something bad happened
     29 			feedWatchAction.Output.0       - Console output from your <exec>, if any; 
     30 				this will depend on what you run in response to a feed change, and if that process produces console output
     31 			feedWatchAction.OldValue.0 - The original value of the node you asked for, from the previous cached version of the feed
     32 			feedWatchAction.NewValue.0 - The changed value of the node you asked for, from the latest version of the feed; 
     33 				if you asked for changes to the test status for performance tests, this could be "PASS"; 
     34 				if you asked for any changes to the feed, this will be the XML datestamp of the last update, eg: 2006-05-04T12:14:33Z
     35 			feedWatchAction.TheValue.0 - Even if the original value is unchanged, this will contain the NewValue. 
     36 				This is useful to determine if the value changed (check if NewValue.0 is defined), but also to have the value, 
     37 				in case you need to pass it to a downstream script. For example, you can check //*[name()='entry'][1]/*/*[name()='build']/@type - which
     38 				if the feed only contains S builds, will never change, and NewValue.0 will be undefined; however, you need the "S" value, 
     39 				so use this property instead of NewValue.0 in order to pass it to the next script.
     40 				
     41 			If you are watching for more than one condition, you can check for feedWatchAction.NewValue.0, feedWatchAction.NewValue.1, feedWatchAction.NewValue.2, etc.
     42 		-->
     43 		
     44 		<!--
     45 		<echoproperties format="text">
     46 			<propertyset><propertyref regex="feedWatchAction\.(Result|Error|Output|NewValue|OldValue|TheValue)\.0"/></propertyset>		
     47 		</echoproperties>
     48 		-->
     49 		
     50 		<echo message="feedWatchAction.OldValue.0 = ${feedWatchAction.OldValue.0}"/>
     51 		<echo message="feedWatchAction.NewValue.0 = ${feedWatchAction.NewValue.0}"/>
     52 		<echo message="feedWatchAction.TheValue.0 = ${feedWatchAction.TheValue.0}"/>
     53 		<echo message="feedWatchAction.OldValue.1 = ${feedWatchAction.OldValue.1}"/>
     54 		<echo message="feedWatchAction.NewValue.1 = ${feedWatchAction.NewValue.1}"/>
     55 		<echo message="feedWatchAction.TheValue.1 = ${feedWatchAction.TheValue.1}"/>
     56 		<echo message="feedWatchAction.OldValue.2 = ${feedWatchAction.OldValue.2}"/>
     57 		<echo message="feedWatchAction.NewValue.2 = ${feedWatchAction.NewValue.2}"/>
     58 		<echo message="feedWatchAction.TheValue.2 = ${feedWatchAction.TheValue.2}"/>
     59 		
     60 		<!-- 3. now we can respond to a changed/unchanged condition if desired -->
     61 		<antcall target="respondToFeedUnchanged"/>
     62 		<antcall target="respondToFeedChanged"/>
     63 
     64 	</target>
     65 	
     66 	<!-- 3a. If not responding via shell <exec>, respond now by checking property(ies) for results -->
     67 	<target name="respondToFeedUnchanged" description="Respond to feed unchanged" unless="feedWatchAction.NewValue.0">
     68 		<echo message="Feed unchanged! Should we do something, like waiting for some period of time and trying again?"/>
     69 		<!-- add steps to do here, like sleeping & re-firing, sending a nag note to someone, etc.  -->
     70 	</target>
     71 	<!-- 3b. If not responding via shell <exec>, respond now by checking property(ies) for results -->
     72 	<target name="respondToFeedChanged" description="Respond to feed changed" if="feedWatchAction.NewValue.0">
     73 		<echo message="Feed changed! Time to do something... but what?"/>
     74 		<!-- add steps to do here, like firing an email, starting a build, etc. -->
     75 		
     76 		<!-- eg., wait 30 seconds and try again -->
     77 		<!-- <echo message="Sleeping..."/>
     78 		<exec executable="sleep" resolveexecutable="true"><arg line="10"/></exec>
     79 		<echo message="Spawning..."/>
     80 		<exec executable="feedWatch.sh" resolveexecutable="true" spawn="true"/> -->
     81 	</target>
     82 	
     83 </project>
     84