<?xml version="1.0"?>
<project name="OpenCover" >
	
	<property name="metrics.password" value="${environment::get-variable('OpenCoverMetricsPwd')}" if="${environment::variable-exists('OpenCoverMetricsPwd')}"/>
	<property name="metrics.password" value="pwd" unless="${property::exists('metrics.password')}" />
    <property name="metrics.endpoint.sequence" value="http://opencover-metrics.herokuapp.com/metrics/opencover_release_sequence/value" />
    <property name="metrics.endpoint.branch" value="http://opencover-metrics.herokuapp.com/metrics/opencover_release_branch/value" />
	
    <target name="update-metrics" failonerror="false">

		<exec program="${solution.folder}/bin/Release/dogfood.cmd"
			workingdir="${solution.folder}/bin/Release" /> 

    <xmlpeek
			file="${solution.folder}/bin/Release/opencovertests.xml"
			xpath="CoverageSession/Summary/@sequenceCoverage"
			property="metrics.sequenceCoverage">
			
		</xmlpeek>
		
		<xmlpeek
			file="${solution.folder}/bin/Release/opencovertests.xml"
			xpath="CoverageSession/Summary/@branchCoverage"
			property="metrics.branchCoverage">
			
		</xmlpeek>
		
		<echo message="metrics are sequence=${metrics.sequenceCoverage} branch=${metrics.branchCoverage}" />
		
		<echo message="sending sequence=${metrics.sequenceCoverage}" />

    <exec program="${curl.exe}" timeout="60000" failonerror="false" 
      commandline="-v --basic -u user:7e_D37$$##Ss4JV -X POST --header &quot;Content-Type: application/json&quot; --data-binary &quot;{\&quot;value\&quot;: \&quot;${metrics.sequenceCoverage}\&quot;}&quot; ${metrics.endpoint.sequence}" />
		
		<echo message="sending branch=${metrics.branchCoverage}" />

    <exec program="${curl.exe}" timeout="60000" failonerror="false" 
      commandline="-v --basic -u user:7e_D37$$##Ss4JV -X POST --header &quot;Content-Type: application/json&quot; --data-binary &quot;{\&quot;value\&quot;: \&quot;${metrics.branchCoverage}\&quot;}&quot; ${metrics.endpoint.branch}" />
		
	</target>
	
</project>