Echo a single line of an SvnAnt error message using Ant

我只是一个虾纸丫 提交于 2019-12-25 05:05:11

问题


If the SvnAnt <export> has an error, the Ant <loadfile> task will show all of it on the console.

<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)

Can I only show this from the logfile and disregard the rest?

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

回答1:


The <linecontains> FilterChain can be given to <loadfile> to extract just the line you want from the file:

<loadfile property="svnLog" srcFile="C:/Logfile.log">
    <filterchain>
        <linecontains>
            <contains value="svn: E170000:"/>
        </linecontains>
    </filterchain>
</loadfile>
<echo>${svnLog}</echo>

Output

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


来源:https://stackoverflow.com/questions/42746637/echo-a-single-line-of-an-svnant-error-message-using-ant

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!