harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r539255 - in /harmony/enhanced/buildtest/branches/2.0: build.xml scripts/cc-exec-adaptor.xml scripts/publisher.xml
Date Fri, 18 May 2007 04:39:35 GMT
Author: smishura
Date: Thu May 17 21:39:33 2007
New Revision: 539255

URL: http://svn.apache.org/viewvc?view=rev&rev=539255
Log:
Apply patch with fixes for default publisher from HARMONY-3501(BT Infra Improvment)

Modified:
    harmony/enhanced/buildtest/branches/2.0/build.xml
    harmony/enhanced/buildtest/branches/2.0/scripts/cc-exec-adaptor.xml
    harmony/enhanced/buildtest/branches/2.0/scripts/publisher.xml

Modified: harmony/enhanced/buildtest/branches/2.0/build.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/buildtest/branches/2.0/build.xml?view=diff&rev=539255&r1=539254&r2=539255
==============================================================================
--- harmony/enhanced/buildtest/branches/2.0/build.xml (original)
+++ harmony/enhanced/buildtest/branches/2.0/build.xml Thu May 17 21:39:33 2007
@@ -129,6 +129,27 @@
         </java>
     </target>
 
+    <target name="test-mail" depends="define-ant-contrib">
+        <xmlproperty file="${scripts.dir}/parameters.xml"
+            collapseAttributes="true" 
+            semanticAttributes="true"
+            prefix="framework"
+        />
+        <ant antfile="${scripts.dir}/cc-exec-adaptor.xml">
+            <property name="suite.name" value="test-mail"/>
+            <property name="test-mail.parameters.cc.from" value="Test-Mail@Test.Com"/>
+            <property name="test-mail.parameters.cc.summary" 
+                      value="${root.dir}/.summary.txt"/>
+            <property name="test-mail.parameters.cc.message" 
+                      value="${root.dir}/README.txt"/>
+            <property name="test-mail.parameters.cc.attachs" 
+                      value="${root.dir}/README.txt,${root.dir}/build.xml"/>
+
+            <property name="mail.execution.status" value="TEST MAIL"/>
+            <property name="framework.parameters.usemail.force" value="true"/>
+        </ant>
+    </target>
+
     <target name="clean" description="clean" depends="init-framework, clean-suites"/>
 
     <target name="distclean" description="distclean">

Modified: harmony/enhanced/buildtest/branches/2.0/scripts/cc-exec-adaptor.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/buildtest/branches/2.0/scripts/cc-exec-adaptor.xml?view=diff&rev=539255&r1=539254&r2=539255
==============================================================================
--- harmony/enhanced/buildtest/branches/2.0/scripts/cc-exec-adaptor.xml (original)
+++ harmony/enhanced/buildtest/branches/2.0/scripts/cc-exec-adaptor.xml Thu May 17 21:39:33
2007
@@ -18,7 +18,7 @@
 <!-- ====================================================================== 
                           CC to Ant Adaptors Execution 
      ====================================================================== -->
-<project name="cc-ant" default="call" basedir=".">
+<project name="cc-ant" default="cc-publish" basedir=".">
 
     <property file="${properties.dump.file}"/>
     <property file="${framework.properties.file}"/>
@@ -39,23 +39,80 @@
             depends="define-ant-contrib"
             if="framework.parameters.usemail">
         <dirname property="publisher.dir" file="${publisher.location}"/>
-        <log message="Calling Publisher ${publisher.location} at ${publisher.dir} for
${suite.name}"/>
+        <log message="Calling Custom Publisher ${publisher.location} at ${publisher.dir}
for ${suite.name}"/>
         <ant dir="${publisher.dir}" 
              antfile="${publisher.location}" 
              target="publish"
              inheritAll="true"/>
     </target>
-
+    
     <!-- Called from CC to launch the default ant publisher for test suite -->
     <target name="cc-publish" 
             depends="define-ant-contrib"
             if="framework.parameters.usemail">
-        <dirname property="publisher.dir" file="${publisher.location}"/>
-        <log message="Calling Publisher ${publisher.location} at ${publisher.dir} for
${suite.name}"/>
-        <ant dir="${publisher.dir}" 
-             antfile="${publisher.location}" 
+
+        <!-- set up mail message file (if it was defined by test suite) -->
+        <get-parameter-value
+            property="mail.message.file" 
+            parameter="${suite.name}.parameters.cc.message"/>
+        <!-- set up mail message summary file
+             (if it was defined by test suite) -->
+        <get-parameter-value
+            property="mail.summary.file" 
+            parameter="${suite.name}.parameters.cc.summary"/>
+        <!-- set up mail attachments -->
+        <get-parameter-value
+            property="mail.attach.files" 
+            parameter="${suite.name}.parameters.cc.attachs"/>
+
+        <!-- compose message from CC logs (it there is no mail.message.file) -->
+        <runtarget target="-compose-message-file"/>
+
+        <!-- do mail notifiaction -->
+        <ant dir="${scripts.dir}" 
+             antfile="${scripts.dir}/publisher.xml" 
              target="publish"
-             inheritAll="true"/>
+             inheritAll="false">
+            <!-- if there are Test Suite specific 'to' and 'from' addresses
+                 use them for mailing -->
+            <propertyset>
+                <propertyref name="${suite.name}.parameters.cc.to"/>
+                <propertyref name="${suite.name}.parameters.cc.from"/>
+                <globmapper from="${suite.name}.parameters.cc.*" to="framework.parameters.usemail.*"/>
+            </propertyset>
+            <propertyset>
+                <propertyref name="thisbuildsuccessful"/>
+                <propertyref name="lastbuildsuccessful"/>
+                <propertyref regex="framework.parameters.*"/>
+                <propertyref regex="mail.*"/>
+            </propertyset>
+        </ant>
+        
     </target>
+
+    <!-- compose message from CC logs -->
+    <target name="-compose-message-file"
+            unless="mail.message.file">
+        <property name="cc.xsl.files.dir"
+                  value="${ext.cc.location}/webapps/cruisecontrol/xsl"/>
+        <property name="mail.message.file"
+                  value="${temp.files.dir}/${suite.name}-email-message.txt"/>
+        <xslt basedir="${scripts.dir}/xslt"
+              in="${logdir}/${logfile}"
+              style="${scripts.dir}/xslt/br.xsl"
+              out="${mail.message.file}"
+              classpath="${ext.xalan.location}:${ext.cc.location}/lib/serializer-2.7.0.jar"/>
+    </target>
+
+    <!-- places the value of the parameter to the provided property -->
+    <macrodef name="get-parameter-value">
+        <attribute name="parameter"/>
+        <attribute name="property"/>
+        <sequential>
+            <condition property="@{property}" value="${@{parameter}}">
+                <isset property="@{parameter}"/>
+            </condition>
+        </sequential>
+    </macrodef>
 
 </project>

Modified: harmony/enhanced/buildtest/branches/2.0/scripts/publisher.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/buildtest/branches/2.0/scripts/publisher.xml?view=diff&rev=539255&r1=539254&r2=539255
==============================================================================
--- harmony/enhanced/buildtest/branches/2.0/scripts/publisher.xml (original)
+++ harmony/enhanced/buildtest/branches/2.0/scripts/publisher.xml Thu May 17 21:39:33 2007
@@ -18,7 +18,7 @@
 <!-- ====================================================================== 
                         Status Publisher Implementation
      ====================================================================== -->
-<project name="publisher" default="run" basedir=".">
+<project name="publisher" default="publish" basedir=".">
 
     <!-- check whether we should send notification or not -->
     <condition property="do.mail">
@@ -36,37 +36,88 @@
             </or>
         </and>
     </condition>
+    <condition property="do.mail">
+        <isset property="framework.parameters.usemail.force"/>
+    </condition>
 
-    <condition property="execution.status"
+    <condition property="mail.execution.status"
                value="BUILD PASSED"
                else="BUILD FAILED">
         <istrue value="${thisbuildsuccessful}"/>
     </condition>
 
     <property name="mail.subject.line"
-              value="${framework.parameters.usemail.subject.prefix} ${execution.status} ${os.name}
${os.arch}: ${suite.name}"/>
+              value="${framework.parameters.usemail.subject.prefix} ${mail.execution.status}
${os.name} ${os.arch}: ${suite.name}"/>
 
     <!-- implement publisher interface -->
-    <target name="publish" if="do.mail" depends="-compose-message">
-        <mail mailhost="${framework.parameters.usemail}"
-              tolist="${framework.parameters.usemail.to}"
-              from="${framework.parameters.usemail.from}"
-              subject="${mail.subject.line}">
-            <message src="${temp.files.dir}/${suite.name}-email-message.txt"/>
-        </mail>
-    </target>
+    <target name="publish" if="do.mail">
+        <log message=""/>
+        <log message="    Sending mail notification:"/>
+        <log message="        smtp: '${framework.parameters.usemail}'"/>
+        <log message="        to: '${framework.parameters.usemail.to}'"/>
+        <log message="        from: '${framework.parameters.usemail.from}'"/>
+        <log message="    Files to attach: ${mail.attach.files}"/>
+        <log message=""/>
 
-    <target name="-compose-message" if="do.mail">
-        <property name="cc.xsl.files.dir"
-                  value="${ext.cc.location}/webapps/cruisecontrol/xsl"/>
-        <property name="transformed.file"
-                  value="${temp.files.dir}/${suite.name}-email-message.txt"/>
-        <xslt basedir="${scripts.dir}/xslt"
-              in="${logdir}/${logfile}"
-              style="${scripts.dir}/xslt/br.xsl"
-              out="${transformed.file}"
-              classpath="${ext.xalan.location}:${ext.cc.location}/lib/serializer-2.7.0.jar"/>
+        <trycatch property="mail.sending.exception">
+        <try>
+            <if>
+                <available file="${mail.summary.file}"/>
+            <then>
+                <!-- 'if' suppresses 'nonexistence' warning -->
+                <loadfile property="mail.summary" 
+                          srcFile="${mail.summary.file}" 
+                          failonerror="false"/>
+            </then>
+            </if>
+            <!-- summary by default -->
+            <property name="mail.summary" value=""/>
+            <loadfile property="mail.message" 
+                      srcFile="${mail.message.file}" 
+                      failonerror="false"/>
+            <!-- empty message by default -->
+            <property name="mail.message" value=""/>
+            <!-- no attachments by default -->
+            <property name="mail.attach.files" value=""/>
+            <mail mailhost="${framework.parameters.usemail}"
+                  tolist="${framework.parameters.usemail.to}"
+                  from="${framework.parameters.usemail.from}"
+                  subject="${mail.subject.line}"
+                  files="${mail.attach.files}">
+                <message>${mail.summary}${mail.message}</message>
+            </mail>
+        </try>
+        <catch>
+            <echo>
+--------
+WARNING: Mail notification sending for Test Suite '${suite.name}' FAILED
+-------- with the following exception:
+${mail.sending.exception}
+
+</echo>
+            <error-notify>
+Mail Notification Sending failed with the following message: ${mail.sending.exception}
+
+----------
+Test Suite '${suite.name}' execution status: ${mail.execution.status}
+            </error-notify>
+        </catch>
+        </trycatch>
     </target>
+
+    <macrodef name="error-notify">
+        <text name="text"/>
+        <sequential>
+            <mail mailhost="${framework.parameters.usemail}"
+                  tolist="${framework.parameters.usemail.to}"
+                  from="${framework.parameters.usemail.from}"
+                  subject="${mail.subject.line}">
+                <message>
+@{text}
+                </message>
+            </mail>
+        </sequential>
+    </macrodef>
 
 </project>
 



Mime
View raw message