国产精品久久久久久久久久东京,亚洲视频免费播放,少妇人妻精品一区二区三区视频,日韩一级品

好房網(wǎng)

網(wǎng)站首頁百科全書 >正文

如何在Jenkins(Ant腳本中使用正則表達式介紹 如何在Jenkins Ant腳本中使用正則表達式詳細情況如何)

2022-07-31 08:41:41 百科全書來源:
導(dǎo)讀 想必現(xiàn)在有很多小伙伴對于如何在Jenkins Ant腳本中使用正則表達式方面的知識都比較想要了解,那么今天小好小編就為大家收集了一些關(guān)于如...

想必現(xiàn)在有很多小伙伴對于如何在Jenkins Ant腳本中使用正則表達式方面的知識都比較想要了解,那么今天小好小編就為大家收集了一些關(guān)于如何在Jenkins Ant腳本中使用正則表達式方面的知識分享給大家,希望大家會喜歡哦。

1、正則表達式是個好東西,功能強大又方便,很多地方都可以使用。在用Jenkins Ant來編寫構(gòu)建自動化測試腳本的時候,也同樣可以使用正則表達式來處理一些比較麻煩的匹配任務(wù),這里分享一下我的經(jīng)驗如下。

2、下載并安裝一個Jenkins服務(wù)器,它是開源的,可以從如下地址了解并下載安裝():

3、https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins

4、進入Jenkins服務(wù)器磁盤系統(tǒng),新建一個文件夾,并在里面建立兩個文件():

5、1. CmdOutput.txt 文件,存放測試數(shù)據(jù)的一個文件;

6、2. BuildTest.xml 文件,用來執(zhí)行構(gòu)建的ant腳本文件。

7、打開CmdOutput.txt 文件,輸入類似如下的測試數(shù)據(jù)():

8、RunTest output: Begin to start TestExecute/TestComplete Instance on remote computer ...*

9、TestExecute.TestExecuteApplication.10

10、Begin to open TestExecute/TestComplete project suite on remote computer ...*

11、2

12、后面的Ant腳本將會先加載讀取這個文件的內(nèi)容,然后把最后一行的返回代碼“2”提取出來.

13、打開BuildTest.xml 文件,輸入如下的Ant腳本()。里面將會使用propertyregex來提取返回代碼,其中property用來指定提取到的值存放在什么屬性里面,input用來指定匹配來源,regexp用來指定正則表達式,select用來指定選擇哪個匹配子項,casesensitive指定是否區(qū)分大小寫。

14、<project name="hello" basedir="." default="Test" xmlns:props="antlib:org.apache.ant.props">

15、<property environment="JenkinsEnv"/>

16、<!--

17、<taskdef resource="net/sf/antcontrib/antcontrib.properties">

18、<classpath>

19、<pathelement location="${JenkinsEnv.ANT_HOME}ant-contrib.jar"/>

20、</classpath>

21、</taskdef>

22、-->

23、<taskdef resource="net/sf/antcontrib/antlib.xml">

24、<classpath>

25、<pathelement location="${JenkinsEnv.ANT_HOME}ant-contrib.jar"/>

26、</classpath>

27、</taskdef>

28、<typedef uri="antlib:org.apache.ant.props" resource="org/apache/ant/props/antlib.xml" classpath="${JenkinsEnv.ANT_HOME}ant-props-1.0Alpha.jar" />

29、<propertyhelper>

30、<props:nested/>

31、</propertyhelper>

32、<!-- *********************************************** -->

33、<target name="GetReturnCode">

34、<loadfile property="CmdOutput" srcFile="CmdOutput.txt"/>

35、<echo message="CmdOutput: ${CmdOutput}" />

36、<propertyregex property="ResultCode"

37、 input="${CmdOutput}"

38、 regexp="^([sS]*)(r?n)+(d{1,})(r?n)*"

39、 select="3"

40、 casesensitive="false" />

41、<echo message="ResultCode: ${ResultCode}" />

42、</target>

43、</project>

44、在Jenkins服務(wù)器上建立一個TEST的Job,然后點擊配置按鈕():

45、在構(gòu)建的標(biāo)簽處,添加一個Invoke Ant,然后分別輸入要構(gòu)建的Ant腳本文件,和要跑的任務(wù)Target():

46、點擊保存按鈕保存上一步做的配置,然后點擊Build Now按鈕開始構(gòu)建Job():

47、構(gòu)建完畢之后,把鼠標(biāo)放到構(gòu)建記錄上面,點擊下拉箭頭,彈出菜單中選擇“Console Output”查看控制臺輸出():

48、結(jié)果頁面中,前面CmdOutput.txt文件中的返回代碼“2”被提取并顯示出來了():

本文到此結(jié)束,希望對大家有所幫助。


版權(quán)說明:本文由用戶上傳,如有侵權(quán)請聯(lián)系刪除!


標(biāo)簽:

熱點推薦
熱評文章
隨機文章