一区二区三区日韩精品-日韩经典一区二区三区-五月激情综合丁香婷婷-欧美精品中文字幕专区

分享

Ant 整合Jenkins自動(dòng)構(gòu)建

 bananarlily 2013-08-01

Jenkins安裝

下載jenkins.war包,運(yùn)行java -jar jenkins.war,即可訪問(wèn)http://localhost:8080/訪問(wèn)jenkins。

或者將jenkins.war包放在Tomcat的Webapp下,啟動(dòng)Tomcat,訪問(wèn)http://localhost:8080/jenkins/。

本例產(chǎn)用后者。

1. 在首頁(yè)選擇系統(tǒng)管理,再右側(cè)頁(yè)面中選擇管理插件。

在可選插件中選擇要安裝的插件,下表為本次測(cè)試中已安裝的插件,有些為默認(rèn)已安裝的插件。

插件

名稱
版本 啟用 Pinned
mailer 1.4 true false
external-monitor-job 1.1 true false
ldap 1.1 true false
pam-auth 1.0 true false
javadoc 1.0 true false
maven-plugin 1.499 true false
ant 1.1 true false
analysis-core 1.48 true false
checkstyle 3.32 true false
cvs 1.6 true false
deploy 1.9 true false
jquery 1.7.2-1 true false
junit-attachments 1.3 true false
ssh-slaves 0.22 true false
subversion 1.39 true false
translation 1.8 true false
email-ext 2.25 true false

2.進(jìn)入jenkins首頁(yè),選擇新建JOB,填寫一個(gè)JOB名稱,選擇“構(gòu)建一個(gè)自由風(fēng)格的軟件項(xiàng)目”。

然后進(jìn)入配置頁(yè)面,也可以首頁(yè)選擇項(xiàng)目,然后選擇配置進(jìn)入此頁(yè)面。

本例的配置如下:

1) 源碼管理選擇Subversion

Repository Url:https://localhost/svn/Diary/trunk/Diary

2) 構(gòu)建觸發(fā)器

選擇Poll SCM

日程表:* * * * * (表示每分鐘都比較,有更改就構(gòu)建)

3) 構(gòu)建

增加構(gòu)建步驟:Invoke Ant

Targets:(什么也沒(méi)寫,默認(rèn)執(zhí)行根目錄下的build.xml)

4) 構(gòu)建后操作

a. Publish Checkstyle analysis results

Checkstyle results:output/diary/checkstyle/checkstyle_report.xml

b. Publish JUnit test result report

Test report XMLs:output/diary/test/data/*.xml

保留長(zhǎng)的標(biāo)準(zhǔn)輸出/錯(cuò)誤 勾選

c. Publish Javadoc

Javadoc directory:output/diary/docs

d.Deploy war/ear to a container

WAR/EAR files:output/diary/diary-1.0.0.war

Container:Tomcat 6.x

Manager user name:admin

Manager password:*****

Tomcat URL:http://localhost:8080

(此處要配置Tomcat的角色和用戶:

在Tomcat的安裝目錄下,找到conf/tomcat-users.xml,修改內(nèi)容如下:

<role rolename="tomcat"/>

<role rolename="role1"/>

<role rolename="manager"/>

<role rolename="admin"/>

<user username="admin" password="admin" roles="admin,manager"/>

<user username="tomcat" password="tomcat" roles="tomcat"/>

<user username="both" password="tomcat" roles="tomcat,role1"/>

<user username="role1" password="tomcat" roles="role1"/>

)

e. Editable Email Notification

Project Recipient List:要發(fā)送的郵件,可多個(gè)用逗號(hào)隔開(kāi)

(此處要配置郵件服務(wù),選擇系統(tǒng)管理->系統(tǒng)設(shè)置:

Jenkins Location

Jenkins URL:http://localhost:8080/jenkins/

配置郵件通知

也可以Extended E-mail Notification中選擇Override Global Settings覆蓋的郵件通知。

在測(cè)試過(guò)程中,郵件通知中沒(méi)有“發(fā)送者的郵箱地址”這一項(xiàng),導(dǎo)致郵件一直不能發(fā)送,選擇了Extended E-mail Notification中的Override Global Settings,在這里填寫信息才將郵件發(fā)送成功。

)

附:

build.xml,增加War包:

001<?xml version="1.0" encoding="UTF-8"?>
002<project name="diary" default="total">
003 
004    <tstamp>
005        <<a href="http://www./program/" target="_blank"><u>for</u></a>mat property="build.latest.dir" pattern="yyyyMMddHHmmss"/>
006        <<a href="http://www./program/" target="_blank"><u>for</u></a>mat property="build.latest.date" pattern="yyyy-MM-dd"/>
007        <format property="build.latest.time" pattern="HH:mm:ss"/>
008    </tstamp>
009 
010    <property name="src.dir" location="src"/>
011     
012    <property name="web.dir" location="WebContent"/>
013     
014    <property name="we<a href="http://www./linux/" target="_blank"><u>bin</u></a>f.dir" location="${web.dir}/WEB-INF"/>
015 
016    <property name="lib.dir" location="${we<a href="http://www./linux/" target="_blank"><u>bin</u></a>f.dir}/lib"/>
017     
018    <property name="build.dir" location="build/classes"/>
019 
020    <!-- Output -->
021    <property name="build.output" location="output"/>
022 
023    <property name="build.output.dir" location="${build.output}/diary"/>
024 
025    <!-- JavaDoc -->
026    <property name="build.output.doc.dir" location="${build.output.dir}/docs"/>
027 
028    <!-- Test -->
029    <property name="test.dir" location="test"/>
030 
031    <property name="build.output.test.dir" location="${build.output.dir}/test"/>
032 
033    <property name="build.output.test.data.dir" location="${build.output.test.dir}/data"/>
034 
035    <!-- CheckStyle -->
036    <property name="build.output.checkstyle.dir" location="${build.output.dir}/checkstyle"/>
037 
038    <property name="checkstyle.xml" location="${build.output.checkstyle.dir}/checkstyle_checks.xml"/>
039     
040    <property name="checkstyle.xsl" location="${build.output.checkstyle.dir}/checkstyle-frames.xsl"/>
041 
042    <!-- Log -->
043    <property name="build.output.log" location="${build.output}/output.log"/>
044 
045    <property name="build.output.log.verbose" location="${build.output}/output_verbose.log"/>
046 
047    <property name="build.output.log.datetime" value="http://xuxujing./blog/[${build.latest.date} ${build.latest.time}]"/>
048 
049    <!-- Jar -->
050    <property file="${src.dir}/base.properties"/>
051 
052    <property name="build.output.requires.dir" location="${build.output.dir}/requires"/>
053 
054    <fileset id="compile.jar" dir="${lib.dir}">
055        <include name="commons-lang-2.4.jar"/>
056    </fileset>
057 
058    <!-- 類路徑 -->
059    <path id="compile.classpath">
060        <fileset refid="compile.jar"/>
061    </path>
062 
063    <path id="test.classpath">
064        <path refid="compile.classpath"/>
065        <pathelement location="${lib.dir}/junit-4.10.jar"/>
066        <pathelement location="${build.dir}"/>
067    </path>
068 
069    <path id="checkstyle.classpath">
070        <pathelement location="${lib.dir}/checkstyle-5.6-all.jar"/>
071    </path>
072     
073     
074    <!-- 記錄日志,日志保存到文件中 -->
075    <record name="${build.output.log}" append="no"/>
076 
077    <record name="${build.output.log.verbose}" append="no" loglevel="verbose"/>
078 
079    <target name="total" depends="zip,war" description="構(gòu)建完成">
080        <echo>${build.output.log.datetime}構(gòu)建完成!</echo>
081    </target>
082     
083    <target name="war" depends="createjar,javadoc" description="生成War">
084        <war destfile="${build.output.dir}/${project.name}-${project.version}.war" webxml="${webinf.dir}/web.xml" duplicate="fail">
085          <fileset file="${web.dir}/*.jsp"/>
086          <lib dir="${lib.dir}">
087            <include name="commons-lang-2.4.jar"/>
088          </lib>
089          <classes dir="${build.dir}">
090            <include name="diary/**/*"/>
091            <include name="${build.dir}/test.property"/>
092          </classes>
093        </war>
094        <echo>${build.output.log.datetime}生成War完成!</echo>
095    </target>
096 
097    <target name="zip" depends="createjar,javadoc" description="生成Zip">
098        <zip destfile="${build.output.dir}/${project.name}-core-${project.version}.zip" duplicate="preserve">
099             <zipfileset dir="${build.output.dir}/docs" prefix="docs"/>
100             <zipfileset dir="${build.output.dir}/requires" prefix="requires"/>
101             <zipfileset file="${build.output.dir}/*.jar"/>
102        </zip>
103        <echo>${build.output.log.datetime}生成Zip完成!</echo>
104    </target>
105 
106    <target name="createjar" depends="test" description="生成Jar">
107        <manifest file="${build.output.dir}/MANIFEST.MF" encoding="utf-8">
108            <attribute name="Built-By" value="http://xuxujing./blog/${user.name}"/>
109            <section name="${project.name}">
110                <attribute name="Implementation-Title" value="http://xuxujing./blog/${project.name}"/>
111                <attribute name="Implementation-Version" value="http://xuxujing./blog/${project.version}"/>
112            </section>
113        </manifest>
114        <jar destfile="${build.output.dir}/${project.name}-core-${project.version}.jar" duplicate="preserve" compress="false" manifestencoding="utf-8" manifest="${build.output.dir}/MANIFEST.MF">
115            <fileset dir="${build.dir}">
116                <exclude name="test/**/*"/>
117                <exclude name="test"/>
118                <exclude name="checkstyle_checks.xml"/>
119                <exclude name="checkstyle-frames.xsl"/>
120                <exclude name="checkstyletask.properties"/>
121                <exclude name="sun_checks.xml"/>
122                <exclude name="checkstyle_checks.xml"/>
123                <exclude name="base.properties"/>
124            </fileset>
125        </jar>
126        <copy todir="${build.output.requires.dir}">
127            <fileset refid="compile.jar"/>
128        </copy>
129        <echo>${build.output.log.datetime}生成Jar完成!</echo>
130    </target>
131 
132    <target name="javadoc" depends="test" description="生成JavaDoc"
133        <javadoc 
134            sourcepath="${src.dir}" 
135            destdir="${build.output.doc.dir}" 
136            packagenames="diary.*" 
137            use="true" 
138            version="true" 
139            windowtitle="${project.name}" 
140            failonerror="true"
141            <classpath refid="compile.classpath"/> 
142        </javadoc>
143        <echo>${build.output.log.datetime}生成JavaDoc完成,詳情可查看${build.output.doc.dir}/index.html!</echo>
144    </target>
145 
146    <target name="test" depends="compilesrc,compiletest" description="批量測(cè)試,并生成html"
147        <junit printsummary="false" haltonfailure="false" errorProperty="test.failed" failureProperty="test.failed"
148            <classpath refid="test.classpath"/> 
149            <formatter type="brief" usefile="false"/> 
150            <formatter type="xml"/> 
151            <!-- 在testcase定義的情況下,單獨(dú)測(cè)試testcase -->
152            <test name="${testcase}" todir="${build.output.test.data.dir}" if="testcase"/> 
153            <!-- 批量測(cè)試 -->
154            <batchtest todir="${build.output.test.data.dir}" unless="testcase"
155                <fileset dir="${build.dir}"
156                    <include name="**/*Test.class"/> 
157                </fileset> 
158            </batchtest> 
159        </junit> 
160        <junitreport todir="${build.output.test.data.dir}"
161            <fileset dir="${build.output.test.data.dir}"
162                <include name="TEST-*.xml"/> 
163            </fileset> 
164            <report format="frames" todir="${build.output.test.dir}"/> 
165        </junitreport> 
166        <fail if="test.failed"
167            ${build.output.log.datetime}批量測(cè)試,并生成html失敗,詳細(xì)可查看${build.output.test.dir}/index.html 
168        </fail> 
169        <echo>${build.output.log.datetime}批量測(cè)試,并生成html完成,詳細(xì)可查看${build.output.test.dir}/index.html!</echo
170    </target>
171 
172    <target name="compiletest" depends="copytest,compilesrc" description="<a href="http://www./linux/" target="_blank"><u>編譯</u></a>測(cè)試<a href="http://www./program/" target="_blank"><u>代碼</u></a>文件">
173        <javac srcdir="${test.dir}" destdir="${build.dir}" includeAntRuntime="false" encoding="UTF-8">
174            <include name="**/*.java"/>
175            <classpath refid="test.classpath"/>
176        </javac>
177        <echo>${build.output.log.datetime}<a href="http://www./linux/" target="_blank"><u>編譯</u></a>測(cè)試<a href="http://www./program/" target="_blank"><u>代碼</u></a>文件完成!</echo>
178    </target>
179 
180    <target name="copytest" depends="init" description="復(fù)制測(cè)試代碼資源文件到編譯目錄">
181        <fileset dir="${test.dir}">
182            <exclude name="**/*.java"/>
183        </fileset>
184        <echo>${build.output.log.datetime}復(fù)制測(cè)試代碼資源文件到編譯目錄完成!</echo>
185    </target>
186 
187    <target name="compilesrc" depends="checkstyle,copysrc" description="編譯源代碼文件">
188        <javac srcdir="${src.dir}" destdir="${build.dir}" includeAntRuntime="false" encoding="UTF-8">
189            <include name="**/*.java"/>
190            <classpath refid="compile.classpath"/>
191        </javac>
192        <echo>${build.output.log.datetime}編譯源代碼文件完成!</echo>
193    </target>
194 
195    <target name="copysrc" depends="init" description="復(fù)制源代碼資源文件到編譯目錄">
196        <copy todir="${build.dir}" includeemptydirs="false">
197            <fileset dir="${src.dir}">
198                <exclude name="**/*.java"/>
199            </fileset>
200        </copy>
201        <echo>${build.output.log.datetime}復(fù)制源代碼資源文件到編譯目錄完成!</echo>
202    </target>
203 
204    <target name="checkstyle" depends="init" description="用Checkstyle校驗(yàn)源代碼">
205        <taskdef name="checkstyle"  classname="com.puppycrawl.tools.checkstyle.CheckStyleTask" classpathref="http://xuxujing./blog/checkstyle.classpath"/>
206        <checkstyle   
207            failOnViolation="false"     
208            failureProperty="checkstyle.failed"    
209            config="${src.dir}/sun_checks.xml">    
210            <fileset dir="${src.dir}" includes="**/*.java"/>     
211            <formatter type="plain"/>     
212            <formatter type="xml" toFile="${build.output.checkstyle.dir}/checkstyle_report.xml"/>     
213        </checkstyle>
214        <xslt style="${checkstyle.xsl}"     
215            in="${build.output.checkstyle.dir}/checkstyle_report.xml"     
216            out="${build.output.checkstyle.dir}/checkstyle_report.html">   
217        </xslt>
218        <echo>${build.output.log.datetime}用Checkstyle校驗(yàn)源代碼完成,詳細(xì)信息查看${build.output.checkstyle.dir}/checkstyle_report.html!</echo>
219    </target>
220 
221    <target name="init" depends="clean,cleanoutput" description="創(chuàng)建輸出目錄">
222        <mkdir dir="${build.dir}"/>
223        <mkdir dir="${build.output.dir}"/>
224        <mkdir dir="${build.output.doc.dir}"/>
225        <mkdir dir="${build.output.test.dir}"/>
226        <mkdir dir="${build.output.test.data.dir}"/>
227        <mkdir dir="${build.output.checkstyle.dir}"/>
228        <copy todir="${build.output.checkstyle.dir}" overwrite="true">
229            <fileset dir="${src.dir}">
230                <include name="checkstyle-frames.xsl"/>
231                <include name="checkstyle_checks.xml"/>
232            </fileset>
233            <filterset>
234                <filter token="output.dir" value="http://xuxujing./blog/${build.output.checkstyle.dir}"/>
235            </filterset>
236        </copy>
237        <echo>${build.output.log.datetime}輸出目錄創(chuàng)建完成!</echo>
238    </target>
239 
240    <target name="clean" description="清理編譯目錄">
241        <delete includeemptydirs="true">
242            <fileset dir="${build.dir}">
243                <include name="**/*"/>
244            </fileset>
245        </delete>
246        <echo>${build.output.log.datetime}編譯目錄清理完成!</echo>
247    </target>
248 
249    <target name="cleanoutput" description="清理輸出目錄">     
250        <delete includeemptydirs="true">
251            <fileset dir="${build.output}">
252                <exclude name="output*.log"/>
253            </fileset>
254        </delete>
255        <echo>${build.output.log.datetime}輸出目錄清理完成!</echo>
256    </target>
257     
258</project>

輸出:

構(gòu)建出錯(cuò)后的輸出,會(huì)發(fā)送郵件到指定郵箱:

01控制臺(tái)輸出
02 
03Started by user anonymous
04Building in workspace C:\Users\xujing\.jenkins\jobs\Diary\workspace
06At revision 20
07no change for https://localhost/svn/Diary/trunk/Diary since the previous build
08No emails were triggered.
09[workspace] $ cmd.exe /C '"ant.bat && exit %%ERRORLEVEL%%"'
10Buildfile: C:\Users\xujing\.jenkins\jobs\Diary\workspace\build.xml
11 
12clean:
13     [echo] [2013-01-21 15:50:49] 編譯目錄清理完成!
14 
15cleanoutput:
16     [echo] [2013-01-21 15:50:49] 輸出目錄清理完成!
17 
18init:
19    [mkdir] Created dir: C:\Users\xujing\.jenkins\jobs\Diary\workspace\output\diary
20    [mkdir] Created dir: C:\Users\xujing\.jenkins\jobs\Diary\workspace\output\diary\docs
21    [mkdir] Created dir: C:\Users\xujing\.jenkins\jobs\Diary\workspace\output\diary\test
22    [mkdir] Created dir: C:\Users\xujing\.jenkins\jobs\Diary\workspace\output\diary\test\data
23    [mkdir] Created dir: C:\Users\xujing\.jenkins\jobs\Diary\workspace\output\diary\checkstyle
24     [copy] Copying 2 files to C:\Users\xujing\.jenkins\jobs\Diary\workspace\output\diary\checkstyle
25     [echo] [2013-01-21 15:50:49] 輸出目錄創(chuàng)建完成!
26 
27checkstyle:
28[checkstyle] Running Checkstyle 5.6 name="code">控制臺(tái)輸出
29 
30Started by user anonymous
31Building in workspace C:\Users\xujing\.jenkins\jobs\Diary\workspace
33At revision 21
34no change for https://localhost/svn/Diary/trunk/Diary since the previous build
35No emails were triggered.
36[workspace] $ cmd.exe /C '"ant.bat && exit %%ERRORLEVEL%%"'
37Buildfile: C:\Users\xujing\.jenkins\jobs\Diary\workspace\build.xml
38 
39clean:
40     [echo] [2013-01-21 16:21:25] 編譯目錄清理完成!
41 
42cleanoutput:
43     [echo] [2013-01-21 16:21:25] 輸出目錄清理完成!
44 
45init:
46    [mkdir] Created dir: C:\Users\xujing\.jenkins\jobs\Diary\workspace\output\diary
47    [mkdir] Created dir: C:\Users\xujing\.jenkins\jobs\Diary\workspace\output\diary\docs
48    [mkdir] Created dir: C:\Users\xujing\.jenkins\jobs\Diary\workspace\output\diary\test
49    [mkdir] Created dir: C:\Users\xujing\.jenkins\jobs\Diary\workspace\output\diary\test\data
50    [mkdir] Created dir: C:\Users\xujing\.jenkins\jobs\Diary\workspace\output\diary\checkstyle
51     [copy] Copying 2 files to C:\Users\xujing\.jenkins\jobs\Diary\workspace\output\diary\checkstyle
52     [echo] [2013-01-21 16:21:25] 輸出目錄創(chuàng)建完成!
53 
54checkstyle:
55[checkstyle] Running Checkstyle 5.6>
56     
57       
58        <ul>
59          <li>Diary.zip (3.1 MB)</li>
60           
61          <li>下載次數(shù): 0</li>
62        </ul>
63       
64     
65     
66   
67 
68 
69 
70   
71   
72   
73<center><div style="margin:10px 0 25px 0">
74<script type="text/javascript">
75/*500*200,創(chuàng)建于2013-4-2 07net01 文章內(nèi)部下*/
76var cpro_id = "u1251111";
77</script>
79 </div></center>
80<p>編譯:<a href="http://www./linux/Ant_zhengheJenkinszidonggoujian_57351_1358757090.html">Ant 整合Jenkins自動(dòng)構(gòu)建</a></p> <p>地址:<a style="font-size:12px;font-family:'宋體'" href="http://www./linux/Ant_zhengheJenkinszidonggoujian_57351_1358757090.html">http://www./linux/Ant_zhengheJenkinszidonggoujian_57351_1358757090.html</a></p><p></p>

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多

    蜜桃臀欧美日韩国产精品| 殴美女美女大码性淫生活在线播放| 东北老熟妇全程露脸被内射| 精品伊人久久大香线蕉综合| 久久亚洲国产视频三级黄| 中文字幕亚洲精品人妻| 国产老女人性生活视频| 午夜精品成年人免费视频| 九九热九九热九九热九九热| 亚洲少妇一区二区三区懂色| 亚洲伦片免费偷拍一区| 国产精品视频第一第二区| 亚洲精品欧美精品一区三区| 老司机精品视频免费入口| 麻豆精品在线一区二区三区| 富婆又大又白又丰满又紧又硬| 成人免费观看视频免费| 国产午夜福利在线观看精品| 中文字幕一区久久综合| 国产一区二区不卡在线视频| 久久精品国产亚洲av麻豆| 亚洲精品中文字幕欧美| 日韩特级黄片免费在线观看| 精品人妻精品一区二区三区| 中文字幕亚洲精品人妻| 亚洲中文字幕综合网在线| 高清一区二区三区大伊香蕉| 丰满人妻一二三区av| 欧美韩国日本精品在线| 免费性欧美重口味黄色| 国产欧美日产中文一区| 毛片在线观看免费日韩| 色婷婷视频国产一区视频| 亚洲一区二区三区福利视频| 国产在线不卡中文字幕| 黄片三级免费在线观看| 国产成人高清精品尤物| 亚洲日本中文字幕视频在线观看| 夫妻性生活黄色录像视频| 激情五月综五月综合网| 午夜成年人黄片免费观看|