jenkins android & iOS build guide

main
Yik Teng Hie 4 years ago
parent 321e2ed394
commit 43625fb099

@ -0,0 +1,146 @@
# Quick Setup Guide (Android & iOS)
## Android
* [Reference](https://bugfender.com/blog/how-to-add-your-first-android-job-to-jenkins/)
### Prerequisite
* Java 8 SDK
```sh
$ sudo apt-get install java-8-openjdk
```
* Android SDK
```sh
sudo apt-get install unzip
# here you paste the link you grabbed in the developer.android.com site
sudo -iu jenkins wget https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip
sudo -iu jenkins mkdir android-sdk
sudo -iu jenkins unzip sdk-tools-linux-3859397.zip -d android-sdk
# this step is important to accept the Android SDK license
yes |sudo -iu jenkins android-sdk/tools/bin/sdkmanager --licenses
```
* Android Emulator (Integration Test)
```sh
# Download emulator
$ sudo -iu jenkins android-sdk/tools/bin/sdkmanager --list --verbose
# create Android Virtual Device instance
$ echo no | $ANDROID_SDK_ROOT/tools/bin/avdmanager -v create avd --force --package 'system-images;android-25;google_apis;armeabi-v7a' --name Android25 --tag google_apis --abi armeabi-v7a
# install Android Emulator as service (Using Supervisor)
$ sudo apt-get install supervisor
# apply configuration file
$ sudo service supervisor restart
$ sudo -iu jenkins android-sdk/platform-tools/adb devices
```
* `Supervisord` configuration file `/etc/supervisor/conf.d/emulator.conf` to run emulator as service
```ini
[program:emulator]
command=/var/lib/jenkins/android-sdk/emulator/emulator -avd Android25 -no-window -noaudio -no-boot-anim -accel on -ports 5556,5557
autostart=true
user=jenkins
environment=ANDROID_SDK_ROOT=/var/lib/jenkins/android-sdk
```
* Jenkins Script for running integration test
```text
ANDROID_SERIAL=emulator-5556
# wait for emulator to be up and fully booted, unlock screen
$ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done; input keyevent 82'
./gradlew connectedAndroidTest
```
### Jenkins build
* Once you have the source code in Jenkins, its time to build. If your project has a Gradle wrapper, thats what you should use
* Task : `assembleDebug`
### Next
* Automate app signing & publishing
* Improve build time (Accelerated Gradle Build)
```sh
$ mkdir -p /var/lib/jenkins/.gradle
$ echo org.gradle.daemon=true | sudo -iu jenkins tee -a /var/lib/jenkins/.gradle/gradle.properties
```
### Configure Jenkins
* Go to Manage Jenkins > Configure System
* Check “Environment variables”
* Add Name: ANDROID_HOME
* Add Value: /var/lib/jenkins/android-sdk
* Click “Apply” then “Save”
# IOS
* [Reference](https://bugfender.com/blog/how-to-add-your-first-ios-job-to-jenkins/)
### Prerequiste
* Apple Mac H/W
* Xcode
```sh
$ xcode-select --install
```
### Sample script
* Build Script
```text
cd Example # again, we need to move directory
mkdir -p output # this directory will contain the output of the tests
xcrun xcodebuild -workspace BugfenderExample.xcworkspace \
-scheme "BugfenderExample" \
-sdk iphonesimulator \
-destination 'platform=iOS Simulator,name=iPhone 6,OS=10.0' \
-derivedDataPath './output' \
test
```
Loading…
Cancel
Save