2011-07-29 50 views
0
<?xml version='1.0' encoding='UTF-8'?> 
<build> 
<actions> 
<hudson.model.CauseAction> 
    <causes> 
    <hudson.model.Cause_-UserCause> 
     <authenticationName>roman</authenticationName> 
    </hudson.model.Cause_-UserCause> 
    </causes> 
</hudson.model.CauseAction> 
<hudson.scm.SubversionTagAction> 
    <build class="build" reference="../../.."/> 
    <tags class="hudson.util.CopyOnWriteMap$Tree"> 
    <no-comparator/> 
    <entry> 
     <hudson.scm.SubversionSCM_-SvnInfo> 
     <url>http://svn.exoplatform.org/projects/jcr-benchmark/trunk</url> 
     <revision>70141</revision> 
     </hudson.scm.SubversionSCM_-SvnInfo> 
     <list/> 
    </entry> 
    <entry> 
     <hudson.scm.SubversionSCM_-SvnInfo> 
     <url>https://anonsvn.jboss.org/repos/exo-jcr/core/trunk</url> 
     <revision>4679</revision> 
     </hudson.scm.SubversionSCM_-SvnInfo> 
     <list/> 
    </entry> 
    <entry> 
     <hudson.scm.SubversionSCM_-SvnInfo> 
     <url>https://anonsvn.jboss.org/repos/exo-jcr/dev-resources/tags/1.2.0</url> 
     <revision>75</revision> 
     </hudson.scm.SubversionSCM_-SvnInfo> 
     <list/> 
    </entry> 
    <entry> 
     <hudson.scm.SubversionSCM_-SvnInfo> 
     <url>https://anonsvn.jboss.org/repos/exo-jcr/docs-style/tags/1</url> 
     <revision>2031</revision> 
     </hudson.scm.SubversionSCM_-SvnInfo> 
     <list/> 
    </entry> 
    <entry> 
     <hudson.scm.SubversionSCM_-SvnInfo> 
     <url>https://anonsvn.jboss.org/repos/exo-jcr/jcr/trunk</url> 
     <revision>4687</revision> 
     </hudson.scm.SubversionSCM_-SvnInfo> 
     <list/> 
    </entry> 
    <entry> 
     <hudson.scm.SubversionSCM_-SvnInfo> 
     <url>https://anonsvn.jboss.org/repos/exo-jcr/junit.framework/tags/1.2.1-GA</url> 
     <revision>1961</revision> 
     </hudson.scm.SubversionSCM_-SvnInfo> 
     <list/> 
    </entry> 
    <entry> 
     <hudson.scm.SubversionSCM_-SvnInfo> 
     <url>https://anonsvn.jboss.org/repos/exo-jcr/kernel/trunk</url> 
     <revision>4673</revision> 
     </hudson.scm.SubversionSCM_-SvnInfo> 
     <list/> 
    </entry> 
    <entry> 
     <hudson.scm.SubversionSCM_-SvnInfo> 
     <url>https://*****.*****.org/repos/****/parent/tags/9</url> 
     <revision>4503</revision> 
     </hudson.scm.SubversionSCM_-SvnInfo> 
     <list/> 
    </entry> 
    <entry> 
     <hudson.scm.SubversionSCM_-SvnInfo> 
     <url>https://*****.*****.org/repos/****/parent/tags/9</url> 
     <revision>4675</revision> 
     </hudson.scm.SubversionSCM_-SvnInfo> 
     <list/> 
    </entry> 
    </tags> 
</hudson.scm.SubversionTagAction> 
<hudson.scm.SVNRevisionState> 
    <revisions> 
    <entry> 
     <string>https://anonsvn.jboss.org/repos/exo-jcr/docs-style/tags/1</string> 
     <long>2031</long> 
    </entry> 
    <entry> 
     <string>https://anonsvn.jboss.org/repos/exo-jcr/dev-resources/tags/1.2.0</string> 
     <long>75</long> 
    </entry> 
    <entry> 
     <string>https://anonsvn.jboss.org/repos/exo-jcr/jcr/trunk</string> 
     <long>4687</long> 
    </entry> 
    <entry> 
     <string>https://anonsvn.jboss.org/repos/exo-jcr/ws/trunk</string> 
     <long>4675</long> 
    </entry> 
    <entry> 
     <string>https://anonsvn.jboss.org/repos/exo-jcr/kernel/trunk</string> 
     <long>4673</long> 
    </entry> 
    <entry> 
     <string>https://anonsvn.jboss.org/repos/exo-jcr/junit.framework/tags/1.2.1-GA</string> 
     <long>1961</long> 
    </entry> 
    <entry> 
     <string>https://anonsvn.jboss.org/repos/exo-jcr/core/trunk</string> 
     <long>4679</long> 
    </entry> 
    <entry> 
     <string>https://anonsvn.jboss.org/repos/exo-jcr/parent/tags/9</string> 
     <long>4503</long> 
    </entry> 
    <entry> 
     <string>http://svn.exoplatform.org/projects/jcr-benchmark/trunk</string> 
     <long>70141</long> 
    </entry> 
    </revisions> 
</hudson.scm.SVNRevisionState> 
<hudson.plugins.chucknorris.RoundhouseAction> 
    <mStyle>THUMB_UP</mStyle> 
    <mFact>Chuck Norris can spawn threads that complete before they are started.</mFact> 
</hudson.plugins.chucknorris.RoundhouseAction> 
<htmlpublisher.HtmlPublisherTarget_-HTMLBuildAction> 
    <actualHtmlPublisherTarget> 
    <reportName>Japex Reports</reportName> 
    <reportDir>TestingResults/</reportDir> 
    <reportFiles>index.html</reportFiles> 
    <keepAll>true</keepAll> 
    <wrapperName>htmlpublisher-wrapper.html</wrapperName> 
    </actualHtmlPublisherTarget> 
    <outer-class reference="../actualHtmlPublisherTarget"/> 
    <build class="build" reference="../../.."/> 
    <outer-class defined-in="htmlpublisher.HtmlPublisherTarget$HTMLBuildAction" reference="../actualHtmlPublisherTarget"/> 
     </htmlpublisher.HtmlPublisherTarget_-HTMLBuildAction> 
    </actions> 
    <number>38</number> 
    <result>SUCCESS</result> 
    <duration>286787</duration> 
    <charset>UTF-8</charset> 
    <keepLog>false</keepLog> 
    <builtOn></builtOn> 
    <workspace>/home/roman/.hudson/jobs/Express-Testing-JCR-Trunk/workspace</workspace> 
    <hudsonVersion>1.417</hudsonVersion> 
    <scm class="hudson.scm.SubversionChangeLogParser"/> 
    <culprits/> 
</build> 

我需要從 <entry> <string>https://anonsvn.jboss.org/repos/exo-jcr/jcr/trunk</string> <long>4687</long> </entry>如何在bash中從XML獲取修訂號?

+1

這是無效的xml – linuts

回答

0

得到修訂(4687)如果url不會改變,並且<修訂>總是來找它,那麼你可以使用以下命令:

$ grep -A 1 '<url>https://anonsvn.jboss.org/repos/exo-jcr/jcr/trunk' test.xhtml | 
     tail -1 | 
     sed -e 's/[^0-9]//g' 
+0

Thaaanks很多! – Roman

3

xgrepxpath實用程序可以幫助您:

xgrep -x '/build/actions/hudson.scm.SubversionTagAction/tags/entry/hudson.scm.SubversionSCM_-SvnInfo[url="https://anonsvn.jboss.org/repos/exo-jcr/jcr/trunk"]/revision/text()' sample.xml 

或者:

xpath -q -e '/build/actions/hudson.scm.SubversionTagAction/tags/entry/hudson.scm.SubversionSCM_-SvnInfo[url="https://anonsvn.jboss.org/repos/exo-jcr/jcr/trunk"]/revision/text()' sample.xml 

在處理XML內容時總是使用XML解析器。如果你沒有,你可能會遇到奇怪的問題,因爲這個經典答案說明:RegEx match open tags except XHTML self-contained tags

相關問題