Jenkins+git+gradle Continuous Integration Environment construction under Linux

Source: Internet
Author: User
Tags rar

I. Project INTRODUCTION and LINUX environment SetupThis tutorial explains the Jenkins+git+gradle continuous integration environment in Linux, followed by the addition of Gerrit Code review and Robotium automated testing1, the basic process is as follows:androidstudio--Gerrit---git (github)----Jenkins---gradle----robotium resultsuse Androidstudio Development, submit to Gerrit for code review, submit to Git after review (you can build git service yourself can also use GitHub), Jenkins listens to git commit situation to trigger build operation, After building using Gradle, use Robotium automation testing.
2. Environment PreparationPc:androidstudio development environment, SECURECRTlinux:jdk, Tomcat, Git, ANDROIDSDK, Gradle, Jenkins
3. Use NETSTAT-TL or service SSH status to see if the SSH service is on, if it is not on, open with service ssh restart, if not installed, use sudo apt-get install Openssh-server install SSH, you can use SECURECRT to operate Linux on the PC side.
remarks: Common commandsifconfigPing 192.168.5.1cat/proc/versionuname-a #可以看到是系统是32位还是64位cat/etc/issuesz download RZ uploadii. installation of JDK, Tomcat, and Git(i), JDK installation1. Download Jdk-6u45-linux-i586.bin2./jdk-6u45-linux-i586.bin installation3. Move the compiled JDK folder to/usr/share4. Setting Environment Variables
remarks: Common commandssudo apt-get install vim
I enter edit mode
ESC returns to command mode
: Wq Save Exit: q!, enter. Discard Change Exit

sudo vim/etc/profile

Java_home=/usr/share/jdk1.5.0_05

Path= $JAVA _home/bin: $PATH

Classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar

Export Java_home

Export PATH

Export CLASSPATH


Source/etc/profile



RM-RF
mv-f

================================

(ii),Tomcat installation

1) Download apache-tomcat-6.0.41.tar.gz

2) #tar-ZXVF apache-tomcat-6.0.41.tar.gz;//Unzip

3) #cp-R apache-tomcat-6.0.41/usr/share/tomcat;//Copy apache-tomcat-6.0.41 to/usr/share/and rename to Tomcat

4)/usr/local/tomcat/bin/startup.sh;//Start Tomcat

Display Using catalina_base:/usr/local/tomcat

Using Catalina_home:/usr/local/tomcat

Using Catalina_temdir:/usr/local/tomcat/temp

Using Java_home:/usr/java/jdk1.6.0_01

To this tomcat has been installed, now using the browser to access http://localhost:8080, the Tomcat default page appears, indicating that the installation was successful.


sudo chmod-r 777 Tomcat #-r recursion


It is also possible to start Jenkins directly without Tomcat because he has embedded the jetty (similar to tomcat)==================(c), install Gitsudo apt-get install git
SCM Tools (SVN, Git, CVS, mercurial, etc.)
Iii. installation of Gradle and Android SDK(i), installation Gradle
1, decompression Gradle:
Unzip Gradle-1.12-all.zip
2. Configuring Gradle Environment variables
sudo vim/etc/profile
gradle_home=/opt/gradle-1.9
Path= $GRADLE _home/bin: $PATH
Export Gradle_homeexport PATH
Source/etc/profile
(b) installation of ANDROIDSDK
1, unpacking Android-studio-bundle-135.1339820-linux.tar

.tar  unpacking: Tar xvf filename.tar pack: Tar cvf filename.tar DirName (Note: Tar is packaged, not compressed!) ) ———————————————. GZ decompression 1:gunzip filename.gz decompression 2:gzip-d filename.gz compression: gzip FileName.tar.gz and. tgz Decompression: Tar zxvf FileName.tar.gz compression: Tar zcvf FileName.tar.gz DirName ———————————————. bz2 extract 1:bzip2-d filename.bz2 extract 2:BUNZIP2 FILENAME.BZ2 compression: Bzip2-z FileName.tar.bz2 decompression: Tar jxvf FileName.tar.bz2 compression: Tar jcvf FileName.tar.bz2 DirName ————————————— ——. BZ Decompression 1:bzip2-d filename.bz decompression 2:bunzip2 filename.bz compression: unknown. Tar.bz decompression: Tar jxvf FileName.tar.bz compression: Unknown ———————————————. Z Decompression: uncompress filename.z compression: Compress filename.tar.z decompression: Tar zxvf filename.tar.z compression: Tar zcvf filename.tar.z DirName —————— —————————. Zip Decompression: Unzip Filename.zip compression: Zip filename.zip DirName ———————————————. rar decompression: rar x filename.rar compression: rar A Filename.rar DirName ———————————————. lha Decompression: lha-e Filename.lha compression: lha-a Filename.lha FileName ———————————————. RPM Unpacking: Rpm2cpio filename.rpm | Cpio-div ———————————————. deb unpacking: ar p filename.deb data.tar.gz | Tar zxf-

After unpacking, copy the SDK inside to/usr/share/android-sdk-linux

2. Configure Environment variables

sudo vim/etc/profile
gradle_home=/opt/gradle-1.9
Path= $GRADLE _home/bin: $PATH
Export Gradle_homeexport PATH
Source/etc/profile
3. Start the simulator
To the Linux GUI, enter android-sdk-linux to  download the emulator image, create the emulator and start it (Execute monitor)


Iv. installation of JenkinsThe process of developing and submitting to GitHub using Androidstudio on the PC side is not.

put Jenkins.war under Tomcat/webapps to restart Tomcatsudo cp jenkins.war/usr/share/tomcat/webapps/
1, install the plug-in:

Sometimes when you install, you'll notice that the list of available plugins is empty. If that's the case, from Advanced tab to the Manage Plugins page, click on Check Now (button available in the bottom righ T of the page) to forcefully check for new updates. Once that 's done and you should see the list of plugins.
Enter Manageplugins
install Git Plugin and GitHub Plugin2. Configure the Environment
Go to "Manage jenkins->configure System" to set the relevant parameters for Jenkins. The main is to set the git and GitHub plugin parameters,
Add the path to the native Git.exe in the path to executable column under Git,
Add local git user.name and user.email information under Git plugin,
Add information about your GitHub account under GitHub Web hooks.
If you want to use the function of the message, you need to add the SMTP server and mailbox information in the Mail Notification column, and then click the Test button after adding the message, this function can be used in the subsequent projects to make the email notification function normal use.
To generate a token on GitHub.
3. Create Job
    Click "New Job", enter "task Name", select "Build a free-style software project" and click "OK". The system automatically enters the task configuration interface. 5. Configure the Build method enter the GIT address in GitHub project. In the "Source Control->git" under the Repository URL input repository Git address (PS: can choose Branch). If you have a private item, you need to add an account password
In build trigger, select Build when a changes is pushed to GitHub and Poll SCM, which are the roles that trigger Jenkins to build and periodically check for updates to the repository when GitHub has a repository update. If there is an update, it triggers Jenkins to build. Note here that the schedule syntax, such as "*/2 * * * *" means checking every 2 minutes.
Built with Gradle and loaded onto the simulator
Final Result:
When we have code push to GitHub on the PC side, Jenkins will automatically acquire it and use gradle to build it and install it on the simulator to test

Jenkins+git+gradle Continuous Integration Environment construction under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.