Continuous integration with Jenkins for Android

Source: Internet
Author: User

On the definition and significance of continuous integration can refer to its Baidu encyclopedia

The main meanings are as follows:

Reduce risk reduction Repeat the process any time, anywhere build the visibility of deployable software enhancement projects Build Team confidence in developing products

Implementation of continuous integration

There are several tools for continuous integration, and I implemented it with Jenkins, which was formerly Hudson.

The introduction to Jenkins is self-searching, and its main feature is the support of a variety of plugins.

Here's how to build an available, continuous integration System for Android.

Tools to use:

1.Android Complete development environment: Android Sdkandroidstudio 1.0.0 stable version Gradle 2.2.1 version Gradle plug-in 1.0.0 Version JDK 1.7 +

2. Tools required by the server:

Latest version of Tomcat,: http://tomcat.apache.org

The latest version of the Jenkins Project War package: http://jenkins-ci.org/

It is recommended that Tomcat be deployed on a Linux or Mac system, mostly with commands to do some compile-time work, and some commands are not available on Windows.

But I don't have a Mac or a Linux system computer, so I built it on Windows.

3. Version control server

Git is recommended, and of course svn is wide, and I'm using Git, which is just a different configuration.

4. Configuration of environment variables

JDK environment variable self-search for configuration

Gradle 2.2.1 Environment variables

Environment variables for Android SDK

Tomcat Environment variables

Configure the Tomcat environment variable 1, new variable name: catalina_base, Variable value: C:\TOMCAT2, new variable name: catalina_home, Variable value: C:\TOMCAT3, open path, add variable value:% Catalina_home%\lib;%catalina_home%\bin 

When the above environment is ready, you can do the following work.

1. Leave the Jenkins.war under the Tomcat installation directory \webapps\, as

2. Start Tomcat

Under CMD, execute the startup command, and wait a moment for Tomcat to automatically deploy Jenkins.

If you execute startup, the report cannot find the command error because the TOMCAT environment variable is not configured, you need to check the configuration

3. Start Jenkins

When Tomcat is started, it is automatically deployed and entered in the browser http://localhost:8080/jenkins/

If the interface of Jenkins is displayed properly, it will be successful, such as:

4. Build a free-style job

Click New to create a free-style task

5. Installing the plugins in Jenkins

Click System Management, then click on the plugin management, go to the plugin management interface, find the optional plugin

Then install the following plug-ins, the name must be the same, not similar

GIT Plugin

Gradle Plugin

There are currently 2 plug-ins are basically enough, can be implemented automatically from the server-side pull code, the implementation of automatic construction

6. Configure the project, if the job name built in step 4th is called Mytestapp

Click Configure to go to the configuration interface of the project

The main configuration has 3 places

1. Git configuration, since the Git plugin has been followed

Then under source control, there will be git options, such as

Repository URL here to fill in the project's git address, preferably HTTPS form, if the address in the form of SSH, it may be difficult to verify the secret key

Credentials place to add authentication methods, generally username and password way, enter their own user name and password.

2. Fill in the branch that Git wants to pull

Depending on your needs to determine the branch, some are develop some are master or other branches.

3. Add build Steps

In the building below, add a build step, select the Invoke Gradle script type

Fill in some commands for the build, as follows

In particular, the operating directory of Jenkins in Windows is generally under C:\Users\Administrator\.jenkins, MAC Environment, need to look in the finder, as if it is a hidden directory

All jobs can be seen in the. Jenkins directory under the job directory, as

But the execution directory of all commands for a job in Jenkins is in the C:\users\administrator\.jenkins\jobs\{job name}\workspace

In this example directory under C:\Users\Administrator\.jenkins\jobs\MyTestApp\workspace, if it is a normal git directory, pull down the code, workspace below should be directly

Is the code directory, but my side of the project below a layer of directory workspace is not the code, but a directory, in this directory execution Gradle build will not find a task,

So I write in the switches for an item:build-p/mytestapp

If it's a normal directory, write it directly:build

All gradle do not need to add gradle, automatically compile the time itself will be added, the complete command is: Gradle build-p/mytestapp or Gradle build

This completes the simple configuration, after saving, to build once, you can see the final running effect.

Continuous integration with Jenkins for Android

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.