說明:本文僅用于個(gè)人記錄
安裝步驟
安裝步驟就不說了痢毒,這里直接說項(xiàng)目配置,安裝步驟參見:http://www.reibang.com/p/74dd11121fc7
創(chuàng)建項(xiàng)目
-
點(diǎn)擊新建item
image.png -
輸入項(xiàng)目名稱--選擇第一個(gè)freestyle projetc--點(diǎn)擊確定
image.png
配置項(xiàng)目
-
進(jìn)入自己的項(xiàng)目索守,點(diǎn)擊配置
image.png
常規(guī)配置
-
描述
image.png -
配置一些擴(kuò)展參數(shù)(給到腳本使用)
image.png
這里配置的是一些簡(jiǎn)單的String 參數(shù)(主要用于上傳apk包,以及發(fā)通知給到企業(yè)微信)
源碼配置
構(gòu)建觸發(fā)器配置
這里可以選按時(shí)輪訓(xùn)(如圖),也可以選擇其他方式,比如自動(dòng)監(jiān)控git提交并觸發(fā)(這里有個(gè)小坑揪胃,好像本地ip直連的gitlab不支持,需要有域名的才行)
更多設(shè)置細(xì)節(jié)參見:http://www.reibang.com/p/ff31b08dadfe
構(gòu)建
這里的gradle直接在jenkins就可以安裝了
最后我們還可以添加一些excute shell 腳本
MSG=${SCM_CHANGELOG}
echo MSG
DISPATCH_APP_KEY="xxxxxx"
IPA_FILE_PATH="/Users/jenkins/.jenkins/workspace/xxx_android/app/build/outputs/apk/daily/release/app-daily-release.apk"
DATE="$(date "+%Y%m%d_%H:%M:%S")"
IPA_UPLOAD_RESPONSE=$(curl -F "file=@${IPA_FILE_PATH}" https://static.xxx.com/upload?scenes=package&output_type=json)
IPA_URL=$(python /Users/jenkins/Desktop/analysis-upload-response.py ${IPA_UPLOAD_RESPONSE})
echo ${IPA_URL}
DISPATCH_REQUEST_URL="https://dispatch.oa.xxx.com/xxx/xxx/xx.json?fappKey=${DISPATCH_APP_KEY}&fappVersion=${DATE}&fappUrl=${IPA_URL}&fsize=40&fversionDesc=Demo"
curl ${DISPATCH_REQUEST_URL}
curl -d "touser=${xxxPushUser}" -d 'agent_id=1000011' -d 'is_textcard_flag=1' -d "description=${xxxDescription}${MSG}" -d "title=${xxxPushTitle}" -d "url=${xxxHref}" http://xxx/weixin/send/msg.json
這里需要注意一些路徑氛琢,在ios和win可能不太一樣喊递,為了省心可以直接配置全路徑。
坑點(diǎn)
項(xiàng)目太大阳似,git拉取失敗
Receiving objects: 93% (4502/4814), 1012.85 MiB | 3.67 MiB/s
Receiving objects: 93% (4504/4814), 1015.59 MiB | 3.84 MiB/s
Receiving objects: 93% (4505/4814), 1021.38 MiB | 3.84 MiB/s
Receiving objects: 93% (4506/4814), 1.00 GiB | 3.89 MiB/s
Receiving objects: 93% (4508/4814), 1.00 GiB | 3.94 MiB/s
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2042)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1761)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$400(CliGitAPIImpl.java:72)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:442)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:886)
... 11 more
ERROR: Error fetching remote repo 'origin'
Finished: FAILURE</pre>
參考鏈接:http://www.reibang.com/p/c8e7ab672a67
解決方案:設(shè)置超時(shí)時(shí)間骚勘,使用淺克隆
淺克隆功能,只clone少部分歷史到本地,這樣可以極大的減少clone的倉庫大小
項(xiàng)目報(bào)內(nèi)存溢出
<pre class="console-output" style="box-sizing: inherit; font-size: 0.95em; white-space: pre-wrap; overflow-wrap: break-word; margin: 0px; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">> **Task :app:mergeDailyReleaseNativeLibs**
Expiring Daemon because JVM heap space is exhausted
Expiring Daemon because JVM heap space is exhausted
> **Task :app:compileDailyReleaseJavaWithJavac** FAILED
系統(tǒng)資源不足俏讹。
有關(guān)詳細(xì)信息, 請(qǐng)參閱以下堆棧跟蹤当宴。
java.lang.OutOfMemoryError: GC overhead limit exceeded
at java.util.EnumSet.noneOf(EnumSet.java:115)
at com.sun.tools.javac.util.JCDiagnostic$Factory.create(JCDiagnostic.java:223)
at com.sun.tools.javac.comp.Resolve$AbstractMethodCheck.reportMC(Resolve.java:779)
at com.sun.tools.javac.comp.Resolve$4$2.report(Resolve.java:882)
at com.sun.tools.javac.comp.Check.checkType(Check.java:553)
at com.sun.tools.javac.comp.Attr$ResultInfo.check(Attr.java:482)
at com.sun.tools.javac.comp.Resolve$MethodResultInfo.check(Resolve.java:1015)
at com.sun.tools.javac.comp.Resolve$4.checkArg(Resolve.java:835)
at com.sun.tools.javac.comp.Resolve$AbstractMethodCheck.argumentsAcceptable(Resolve.java:735)
at com.sun.tools.javac.comp.Resolve$4.argumentsAcceptable(Resolve.java:844)
at com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:579)
at com.sun.tools.javac.comp.Resolve.selectBest(Resolve.java:1446)
at com.sun.tools.javac.comp.Resolve.findMethodInScope(Resolve.java:1633)
at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1704)
at com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1677)
at com.sun.tools.javac.comp.Resolve$14.doLookup(Resolve.java:2689)
at com.sun.tools.javac.comp.Resolve$BasicLookupHelper.lookup(Resolve.java:3097)
at com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3348)
at com.sun.tools.javac.comp.Resolve.resolveOperator(Resolve.java:2685)
at com.sun.tools.javac.comp.Resolve.resolveBinaryOperator(Resolve.java:2726)
at com.sun.tools.javac.comp.Attr.visitBinary(Attr.java:3061)
at com.sun.tools.javac.tree.JCTree$JCBinary.accept(JCTree.java:1785)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)
at com.sun.tools.javac.comp.Attr.visitParens(Attr.java:2986)
at com.sun.tools.javac.tree.JCTree$JCParens.accept(JCTree.java:1661)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:618)
at com.sun.tools.javac.comp.Attr.visitIf(Attr.java:1581)
at com.sun.tools.javac.tree.JCTree$JCIf.accept(JCTree.java:1269)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:576)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:645)
at com.sun.tools.javac.comp.Attr.attribStats(Attr.java:661)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDailyReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.</pre>
修復(fù)方案:按照箭頭指示配置即可
鍵:GRADLE_OPTS
值:-Dorg.gradle.jvmargs=-Xms1024M -Xmx8192M -XX:PermSize=512M -XX:MaxPermSize=2048 -XX:+CMSClassUnloadingEnabled -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
鍵:JAVA_OPTS
值:-XX:MaxPermSize=2048M
-jvmargs 代表后面是設(shè)置jvm的參數(shù)
-Xms 128M JVM設(shè)置最小分配的堆內(nèi)存
-Xmx 512M JVM允許最大分配的堆內(nèi)存,按需分配
-XX:PermSize=64M JVM設(shè)置分配最小的非堆內(nèi)存
-XX:MaxPermSize=128M JVM最大允許分配的非堆內(nèi)存泽疆,按需分配
參考地址:https://stackoverflow.com/questions/14762162/how-do-i-give-jenkins-more-heap-space-when-its-running-as-a-daemon-on-ubuntu
mac 腳本無訪問權(quán)限
可以把腳本直接放到當(dāng)前用戶目錄即可