Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ Construction of Android and iOS apps use Jenkins Automation     - How Vim playing a mature IDE (Linux)

- Linux security-related basics (Linux)

- AngularJS asynchronous service testing and Mocking (Programming)

- Installation salt-minion on RHEL5 (Linux)

- Digital jQuery scrolling effect (Programming)

- Linux system performance and usage activity monitoring tools -Sysstat (Linux)

- MySQL use the integer type (Database)

- namespace mechanism Linux kernel analysis (Linux)

- Why use Docker (Programming)

- Ubuntu 14.04 compile, install, configure, the latest development version GoldenDict (Linux)

- Piostat - Monitoring and Statistics Linux process (Linux)

- Articles do not resolve after opening under Ubuntu WordPress setting a fixed link (Server)

- Batch download files using the explorer under Windows Server 2008 R2 (Server)

- CentOS 7.0 Experience with previous versions (Linux)

- To install Samba server on CentOS 6.6 (Server)

- MySQL use benchmarking tool sysbench (Database)

- The temporary operation of the document mkstemp on Linux (Linux)

- APT-GET commonly used Linux command (Linux)

- How to use jgit to manage Git submodule (Linux)

- Getting Started with Linux system to learn: how to install autossh (Linux)

  Construction of Android and iOS apps use Jenkins Automation
  Add Date : 2018-11-21      

With the evolution of business needs, the complexity of the project will gradually increase, the increasingly strong automation practice. In fact, automation engineering has been the goal of our efforts, we can improve productivity, maximize reduce the probability of human error, to achieve a number of complex business requirements strain.
Scene follows, testers now need to test each new version, developers are required to package and put ftp, testers and ftp to copy from the local (or using the phone's ES File Manager), and then install. Especially near the hair version of the week, the new version almost every day. In this case, there are two effects: first, interrupted the progress of the development developers; second, developers packaged low efficiency, especially ios, the words ring true, always hit the wrong (may be an issue the certificate) .
To solve this problem, you must move the client application to automate the construction. Specifically, it is to use continuous integration (CI) system jenkins, automatically detect and pull the latest code, and automatic packaging of Android apk ios the ipa, automatically uploaded to the measured distribution platform dandelions. (Next, testers simply open one (or more) fixed site, scan the two-dimensional code, you can download the latest version ...)


To compile because ios, so I chose Mac OSX 10.11.1.
Regardless of which operating system, jenkins configuration is the same.

Installation Jenkins

Official website address: http: //jenkins-ci.org/

// Use the brew installation
brew install jenkins
// Start direct service to start running jenkins

Default access http: // localhost: 8080 /, enter jenkins configuration page.

Jenkins related plug-ins installed

Click System Administration> Manage Plugins> Optional plug-ins, you can search for the following plug-in installation

git plugin (GIT plugin)
ssh plugin (SSH Credentials Plugin)
Gradle plugin (Gradle plugin) - android dedicated
Xcode plug (Xcode integration) - ios dedicated

New Job

Home Page, New -> Build a free-style software project can be.
For similar projects, you can select -> copy an existing Item, the name of the task you want to copy, enter the first character will have a job other smart tips.

Configure git repository

If you have installed git plugin appears in the Git source code management will, after selected:
Repositories -> https://github.com/openproject/ganchai, even if it is ssh configuration Credentials.
Branch -> * / master, select a branch to compile the code.

If a private warehouse (eg git: //xxxxx.git), click Credentials - Add, the dialog box, the most simple configuration sshkey

Configuring automatic pull the latest code

In constructing the trigger, there are two automatic pull code and compile strategies:

1. Set the Poll SCM, set the timer, regularly check code updates, updates the compiler, or do not compile (I do with this).

2. You can also set the Build periodically, periodically compile task.

About timer format, I can only excerpt from the Internet a little tricky for some little explanation:

. This field follows the syntax of cron (with minor differences) Specifically, each line consists of 5 fields separated by TAB or whitespace:


MINUTE Minutes within the hour (0-59)
HOUR The hour of the day (0-23)
DOM The day of the month (1-31)
MONTH The month (1-12)
DOW The day of the week (0-7) where 0 and 7 are Sunday.

To specify multiple values ​​for one field, the following operators are available. In the order of precedence,

   * '*' Can be used to specify all valid values.
   * 'M-N' can be used to specify a range, such as "1-5"
   * 'MN / X' or '* / X' can be used to specify skips of X ''s value through the range, such as "* / 15" in the MINUTE field for "0,15,30,45" and "1-6 / 2" for "1,3,5"
   * 'A, B, ..., Z' can be used to specify multiple values, such as "0,30" or "1,3,5"

Empty lines and lines that start with '#' will be ignored as comments.
In addition, @yearly, @annually, @monthly, @weekly, @daily, @midnight, @hourly are supported.
Here are two examples:

// Every minute
* * * * *
// Every 5 mins past the hour
5 * * * *

Configuration gradle - android dedicated

Please ios friends drifting.
If you install the plug-gradle successful, it should appear under the figure Invoke Gradle script, configure the look

$ {WORKSPACE} represents the current workspace directory under the job is mainly to store code. More environment variables refer to the appendix at the end of the text.
In this way, it can automatically generate apk app in the project under the build / outputs / apk.
Compilation failed? You may want to address the following two questions:

1.gradle no configuration environment variable.
For example, I configured in / etc / profile clicking GRADLE_HOME:

export GRADLE_HOME = '/ home / jay / .gradle / wrapper / dists / gradle-2.2.1-all / c64ydeuardnfqctvr1gm30w53 / gradle-2.2.1'
export PATH = $ GRADLE_HOME / bin: $ PATH
2. find local.properties in sdk definition.
Because in general local.properties not added to the repository.
So we need to manually copy the next Project directory under $ {WORKSPACE} (refer to himself Android Studio project structure).
Definition local.properties, where records look, make a copy:

sdk.dir = xx / xx / android-sdk
Then compile the general will compile successfully, of course, when those third-party libraries need to re-download, the compiler may be slow.

Configuration xcode - ios dedicated

Please android students drifting away.
After installing Xcode plug-in, you can see the following chart interface and configuration

There are two caveats.

1. Signed
2. Need Shared Schema file.
Dandelion uploaded to the platform

In the official website of the document, there are instructions by uploading app linux platform critical code

curl -F "file=@/tmp/example.ipa" -F "uKey =" -F "_api_key =" http://www.pgyer.com/apiv1/app/upload


# $ {Version} put it as v1.0
curl -F "file=@/home/xxx/release/ganchai-release-${version}-0101-dev.apk" -F "uKey = 231xxxxe6" -F "_api_key = 0xxxx499" -F "publishRange = 2" http://www.pgyer.com/apiv1/app/upload

This completes a dandelion uploaded to the app.

In fact, we may be faced with more complex scenarios, such as the above $ {version}, while the version in build.gradle defined as follows:

ext {
    compileSdkVersion = 22
    buildToolsVersion = "23.0.1"
    minSdkVersion = 10
    targetSdkVersion = 22
    versionCode = 1111
    versionName = "v1.2.0.0"

Need to find ways to read versionName, and then spell out the final name of the file, so after the next upgrade version can dynamically upload the app to the dandelion.

# Use the sed command to read, using cut cut, eventually dynamic read versionName
version = `sed -n '21, 1p '$ {WORKSPACE} /xxx/build.gradle | cut -c20-27`

This is the android apk upload process, appropriate, ios is uploaded ipa, the method is the same, not repeat them.


After the developers released version of the work automation, this way, at any time convenient for testers and pull to build the latest version, but the liberation of the developer's own version of the work made, a word, good!


Jenkins those environment variables defined:

The following variables are available to shell scripts

The current build number, such as "153"
The current build id, such as "2005-08-22_23-59-59" (YYYY-MM-DD_hh-mm-ss)
The display name of the current build, which is something like "# 153" by default.
Name of the project of this build, such as "foo" or "foo / bar". (To strip off folder paths from a Bourne shell script, try: $ {JOB_NAME ## * /})
String of "jenkins - $ {JOB_NAME} - $ {BUILD_NUMBER}". Convenient to put into a resource file, a jar file, etc for easier identification.
The unique number that identifies the current executor (among executors of the same machine) that's carrying out this build. This is the number you see in the "build executor status", except that the number starts from 0, not 1.
Name of the slave if the build is on a slave, or "master" if run on master
Whitespace-separated list of labels that the node is assigned.
The absolute path of the directory assigned to the build as a workspace.
The absolute path of the directory assigned on the master node for Jenkins to store data.
Full URL of Jenkins, like http: // server: port / jenkins / (note: only available if Jenkins URL set in system configuration)
Full URL of this build, like http: // server: port / jenkins / job / foo / 15 / (Jenkins URL must be set)
Full URL of this job, like http: // server: port / jenkins / job / foo / (Jenkins URL must be set)
Subversion revision number that's currently checked out to the workspace, such as "12345"
Subversion URL that's currently checked out to the workspace.
- MongoDB fragmentation (Cluster) (Database)
- MySQL concat function is SQL injection (Linux)
- PSUADE installation under Linux (Linux)
- Java string equal size comparison (Programming)
- Linux command line ten magic usage (Linux)
- Linux initialization init system - UpStart (Linux)
- 8 Docker knowledge you may not know (Server)
- Distributed File System FastDFS deployment (Server)
- Linux kernel socket protocol stack routing lookup cache mechanism (Linux)
- Transfer MySQL database to MariaDB (Database)
- After Ubuntu Password Forgot your way back (Linux)
- Spring loaded container finishes executing a method (Programming)
- Linux system performance tuning of Analysis (Linux)
- ARM assembler instruction debugging method (Programming)
- Hutchison DG standby database CPU consumption reached bottleneck repair (Database)
- Modern Objective-C syntax and new features (Programming)
- MySQL Error Code Complete (Database)
- Linux Network Analysis Tcpdump Command Guide (Linux)
- Installation Sublime Text 3 (Build 3065) text editor in Ubuntu (Linux)
- Rails project prepared some tips small experience (Linux)
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.