Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ Construction of Android and iOS apps use Jenkins Automation     - Two network security scanning tools under ubuntu (Linux)

- Ubuntu server 8.04 Firewall Guide (Linux)

- Chrome plug-in management, online-offline installation, part of the plug presentations (Linux)

- Teach you how to synchronize Microsoft OneDrive in Linux (Linux)

- Using Ruby to build a simple HTTP service and sass environment (Server)

- Ubuntu install code editor Sublime Text 3 (Linux)

- The ORA-01113 error is handled with BBED without archiving (Database)

- Traffic monitor Linux Python Version (Programming)

- Windows environment Android Studio v1.0 Installation Guide (Linux)

- C # socket udp broadcast (Programming)

- Linux using RAID how to use Mdadm Tool Management Software RAID (Linux)

- Android Fragment everything you need to know (Programming)

- How SSHfs mount a remote file system on Linux (Linux)

- Use CutyCapt to convert HTML pages to png images on Linux (Linux)

- Oracle database file path changes (Database)

- Linux landing problem (Linux)

- Why is better than Git SVN (Linux)

- Ubuntu user use PPA to install Uget 2.0.5 (Linux)

- Linux System Getting Started Learning: Linux common log file (Linux)

- To setup NOTRACK and TRACK of conntrack in iptables (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.
- Fedora 22 how to play rmvb mp4 mkv video files (Linux)
- The Linux C truncate function clears the file notes (Programming)
- Linux Live CD lets your PC is no longer secure (Linux)
- Oracle 11g can not export a variety of empty table solution (Database)
- Father of Python: Why Python zero-based index (Programming)
- To install the Oracle process notes on Oracle Linux 4u4 (Database)
- ORA-12545: Connection failed because the target host or object does not exist (Database)
- Oracle to read and modify the data block process (Database)
- MySQL Data Types (Database)
- Linux distributed message queue RocketMQ deployment and monitoring - Dual Master (Server)
- Oracle Database asynchronous IO cause slow query response (Database)
- 10 Regulation of painless SQL Schema (Database)
- Android memory optimization of the memory cache (Linux)
- Red Flag Linux Desktop 6.0 hard disk installation guide (Programming)
- Django url () function Detailed (Programming)
- Detailed installation of CentOS 6.x (Linux)
- Ubuntu 15.10 install the latest Arduino IDE 1.6.7 (Linux)
- Linux stand-alone OGG synchronous Oracle 11g DB test (Database)
- The Gitlab migrated to Docker container (Server)
- Sorting Algorithm (1) Quick Sort C ++ implementation (Programming)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.