I haven't recorded what I learned for a long time. Now join the new company, do a continuous integration practice practiced hand, during a lot of problems encountered in this record.
First of all, Jenkins refreshed a few times directly hung up, in fact, there are not many job running. This question does not see so, finally mentor found is memory problem, the default value is too low, must be set up a bit. See link.
Then the project source code is placed on the self-built Gitlab, installed a gitlab hook plug-in, which will help you to install GIT-related plug-ins, and hooks can receive gitlab there is a change of code there when the message sent, and then automatic build.
Prepare before building:
Mentor said that when the build task is many, the result of saving too much Jenkins will slow the card, so set to discard the old build.
On the Jenkins server installed git but how can not even repository, the error is:
Failed to connect to Repository:command "git config--local credential.helper store--file=/tmp/git2956041026506359040.c Redentials "returned status code 129:stdout:stderr:error:unknown option ' Local '
Google a find is redhat under the Yum git installed by default is 1.7.1, to install a higher version of the line. See LINK1,LINK2.
After this has been found not yet, after a half-day finally found in the Jenkins system setup inside the git path is good. But I don't have Jenkins on my own Ubuntu machine that can be used directly, and it's probably an installation path or an environment variable.
Because the project needs to build a jar inside an Android project, and then put it in another Android project and then package a jar. I'm not happy with multiple jobs to build, so I installed the multiple SCMS plugin to manage. Set the local folder and empty the repository before each clone.
On the Redhat with Android environment times a lot of errors, all kinds of packages not installed, Link1,link2. And then compile with Javac, always find/android-sdk-linux/platforms/android-19/android.jar, and later found the need to change android-19 and Android.jar permissions. Remember when the Android SDK on Ubuntu, the official online package basically nothing, but also to make their own one by one, it is really egg pain.
"Todo"
Build: Build.xml
Post-Build steps:
The job itself determines if build is successful, because to build multiple project, we can write the result into result.xml, so that it is easy to see which one is wrong. At the same time, it is convenient to add test case later.
This is done by first giving a result template containing all the build and case, and then setting it according to the success or not. The full log can look at the console output. It's not so much trouble if you run with JUnit test.
<Testsuite> <testcaseClassName= "buildid:001"name= "BUILD:ANDROIDADSDK"> </testcase> <testcaseClassName= "buildid:002"name= "Build:androidadsupdate"> </testcase></Testsuite>
ImportSYSPrintSys.argv[1]PrintSys.argv[2]model= File ("Result.xml","R") Result= File ("Restemp.xml","W") forDatainchmodel:result.write (data)ifSYS.ARGV[1]inchData:ifSYS.ARGV[2]inch "fail": Result.write ("<error message=\ "fail\" >\n") Result.write ("</error>\n") elifSYS.ARGV[2]inch "Pass": Result.write ("<system-out>\n") Result.write ("pass\n") Result.write ("</system-out>\n") Model.close () result.close ()
When running ant in the shell, I found that the information of build failure is not good to catch and find a workround on the net.
Echo "=========== build jar ..."{ant Build&&{python setresult.py androidadsdk passRMResult.xmlMVRestemp.xml result.xmlEcho "=========== build jar successfully ..." }} ||{python setresult.py androidadsdk failRMResult.xmlMVRestemp.xml result.xmlEcho "=========== fail to build JAR!!!"}
Send email This is quite simple, can next Email-ext plug-in, build success can also send mail.
Jenkins live on Redhat build the Android Project jar package