使用Ant回显单行SvnAnt错误消息

时间:2017-03-12 11:08:29

标签: java svn ant svnant

如果SvnAnt <export>出错,Ant <loadfile>任务将在控制台上显示所有内容。

<svn refid="svn.settings" logFile="C:/Logfile.log">
    <export destpath="LOCAL Location" srcUrl="Source Url" />
</svn>
<loadfile property="svnLog" srcFile="C:/Logfile.log"/>
<echo>${svnLog}</echo>
[echo] <Export> started ...
[echo] export --no-auth-cache -r HEAD https://lbsm8-svn.path.local/svn/DB_Scripts/SCRIPTS/Reporting/FTR/ORAX/ftr1241000000430105_orax.pbd D:\Copyof\anttt\RET\ORA
[echo] svn: E170000: URL'https://svn.apache.org/repos/infra/websites/production/commons/content/proper/commons-rng'
[echo] <Export> failed.
[echo] the execution failed for some reason. cause: Can't export
[echo]  at org.tigris.subversion.svnant.commands.SvnCommand.ex(Unknown Source)
[echo]  at org.tigris.subversion.svnant.commands.Export.execute(Unknown Source)
[echo]  at org.tigris.subversion.svnant.commands.SvnCommand.executeCommand(Unknown Source)
[echo]  at org.tigris.subversion.svnant.SvnTask.executeImpl(Unknown Source)
[echo]  at org.tigris.subversion.svnant.SvnTask.execute(Unknown Source)
[echo]  at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)

我是否只能从日志文件中显示此内容并忽略其余内容?

[echo] svn: E170000: URL'https://svn.apache.org/repos/infra/websites/production/commons/content/proper/commons-rng'

1 个答案:

答案 0 :(得分:1)

可以<loadfile> <linecontains> FilterChain<loadfile property="svnLog" srcFile="C:/Logfile.log"> <filterchain> <linecontains> <contains value="svn: E170000:"/> </linecontains> </filterchain> </loadfile> <echo>${svnLog}</echo> 提取您想要的文件行:

[echo] svn: E170000: URL'https://svn.apache.org/repos/infra/websites/production/commons/content/proper/commons-rng'

输出

event