Jenkins 五: 構建Ant項目


1. 點擊“新建”,在“Item名稱”欄輸入要構建的項目名,比如“Ant_project”,選擇“構建一個自由風格的軟件項目”,點擊“OK”按鈕。

2. 找到“源碼管理”-> “Subversion”.

在 “Repository URL”欄輸入源碼地址。

3. 找到“ 構建”。點擊 “增加構建步驟”,選擇”Invoke Ant”。

在“Ant Version”里面選擇我們自己配置的Ant版本。

在”Targets“里面輸入我們構建時執行的targets。比如”clean init build“。

備注:

target屬於Ant的東西,我們可以在項目的build.xml中找到所有的targets。比如我剛剛輸入”clean init build“,那么build.xml中一定有target 的name是 clean 的, init的,以及build的。

具體有哪些target可以定義,可以參見Ant的內容。

build.xml可以自己寫,也可以通過在eclipse 中自動生成。自動生成方式: 右擊項目-> Export –> General –> Ant Buildfiles –> Next –> Finish,就可以看到該項目路徑下自動生成了build.xml文件。

4. 找到”構建后操作“。點擊”增加構建后操作步驟 “,選擇“E-mail Notification”。

在 “Recipients”欄輸入需要通知的用戶郵件地址,比如 user1@qq.com

注意: 默認選中的是“每次不穩定的構建都發送郵件通知”,所以構建成功是看不到郵件通知的。

5. 點擊“保存”按鈕。

6. 點擊“立即構建”。

7. 可以看到生成了“#1”。點擊“#1”,點擊“Console Output”。可以看到“控制台輸出”里面包含所有build過程的細節日志。

clean:

init:
    [mkdir] Created dir: xxxxxxxxxxxxxxxxxxxx

build-subprojects:

init:

build-project:
     [echo] xxxxxxxxxxxxxxxxxxxxxxxxxxxx
    [javac] Compiling 1 source file to xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

build:

BUILD SUCCESSFUL
Total time: 1 second
Finished: SUCCESS

備注:

首先執行了 clean target。

然后執行了 init target。

之后准備執行 build target,但是build target 在build.xml中定義了依賴於 "build-subprojects,build-project“ target ,所以我們看到接下來執行了 build-subprojects target。接下來執行 build-project時定義了依賴於 init target,所以又執行了 init target,然后執行 build-project,最后執行 build target。

最后提示build成功。

在頁面左側也可以看到”Executed Ant Targets“,列出所有執行過的 Targets。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM