我当前的代码(build.xml)使我能够在成功构建时发送电子邮件,但是当失败时,没有任何反应。通过类似于“........ -DrepositoryAddress =%1 -DbuildResultUUID =%2 startPublish”的命令从build.bat文件调用目标(对于所有目标,按顺序startActivity-> startPublish-> mailer-> startActivity)
现在,我还希望在构建失败时发送电子邮件通知。我猜trycatch会帮助我完成任务,但是如何?不确定,在哪里/如何放置它(编辑它?)?我使用了trycatch,它给了我一些类似“问题:无法创建任务或输入trycatch”的内容。当前脚本/ xml文件中需要进行哪些修改才能启用发送指示构建状态(成功或失败)的电子邮件的此功能。请指导/帮助。谢谢。
<target name="startActivity">
<fail message="Missing repositoryAddress" unless="repositoryAddress"/>
<fail message="Missing buildResultUUID" unless="buildResultUUID"/>
<fail message="Missing activityLabel" unless="activityLabel"/>
<!-- Replace ADMIN with your real credentials. -->
<startBuildActivity
buildResultUUID="${buildResultUUID}"
label="${activityLabel}"
autoComplete="true"
repositoryAddress="${repositoryAddress}"
userId="BuildAdmin"
password="Abc1234"/>
</target>
<target name="startPublish">
<sleep seconds="10"/>
<fail message="Missing repositoryAddress" unless="repositoryAddress"/>
<fail message="Missing buildResultUUID" unless="buildResultUUID"/>
<artifactfilePublisher repositoryAddress="${repositoryAddress}"
userId="BuildAdmin"
password="Abc1234"
buildResultUUID="${buildResultUUID}"
filePath="E:\Setup.msi"
label="Installer" />
</target>
<target name="mailer">
<property name="report" value="E:\Report.html"/>
<mail from="dmin@company.com" messagemimetype="text/html" charset="ISO-7779-1" messagefile="${report}" mailhost="HMMMM.company.com" mailport="25" tolist="admin@company.com" subject="Build status" />
</target>
<taskdef name="startBuildActivity"
classname="com.ibm.team.build.ant.task.StartBuildActivityTask" />
<taskdef name="artifactfilePublisher"
classname="com.ibm.team.build.ant.task.ArtifactFilePublisherTask" />
</project>'