⾃自⼰己的 Jenkins ⾃自⼰己來來
For Android Developer
Andyang@Twjug
X
AGENDA
▸ What Jenkins
▸ Why Jenkins
▸ Workflow
▸ Install Jenkins
▸ First Job
▸ Integration with SCM
▸ Set up with Android
▸ Run Test
▸ Build
▸ Deploy to internal/production EVN
▸ Reporting
▸ Notify to slack
▸ What’s next?
▸ Jenkins pipeline
聽過 JENKINS 嗎?
團隊有使⽤用 JENKINS 嗎?
沒有?!沒關係!
⾃自⼰己的 JENKINS ⾃自⼰己來來!
WHAT JENKINS
▸ Open source written in Java
▸ CI
▸ build
▸ test
▸ source code analysis
▸ CD
▸ delivery/deploy
▸ deploy to staging/production
WHY JENKINS
▸ 懶懶
▸ 懶懶
▸ 懶懶
▸ 可重複執⾏行行 (Repeatable)
▸ ⾃自動化 (Automation)
▸ 定期執⾏行行 (cron job)
▸ 各種 web hook
▸ 基於以上幾點就可以很懶懶但不容易易出錯 (應該拉?!
WORKFLOW
Jenkins
QA
push
developer
Beta
Bug report
Slack
bug/feature/support
PM
feature/support
Github
pull
trigger
INSTALL JENKINS
▸ Using war
▸ download jenkins war
▸ java -jar jenkins.war --httpPort=8080
▸ open browser http://localhost:8080
INSTALL JENKINS
▸ Install on Server (Ubuntu)
▸ sudo apt-get update
▸ sudo apt-get install jenkins
▸ vim /etc/default/jenkins
▸ HTTP_PORT=8080
▸ sudo systemctl start/stop/status jenkins
▸ open browser http://lp_address_or_domain:8080
INSTALL JENKINS
▸ unlock jenkins
▸ Install suggested plugins
▸ setting admin user
INSTALL JENKINS
▸ Install on Windows
▸ 下載安裝檔
▸ 下⼀一步 -> 下⼀一步 -> 下⼀一步 … 完成!
▸ 需要注意之處:
▸ Shell script 改寫成 DOS 使⽤用的 Batch script
▸ Job 名稱不能為中⽂文,否則執⾏行行 Batch script 會卡住
▸ Workspace 路路徑太長會造成 Gradle task 出現錯誤
FIRST JOB
▸ Free style
▸ pipeline
▸ Others…..
INTEGRATION WITH SCM
▸ Git/Mercurial/SVN
▸ Git
▸ repo url
▸ Credentials
▸ Branch
▸ Additional behaviors (只列列我有⽤用的)
▸ sub module
JENKINS CREDENTIALS
▸ Credentials -> global -> add credentials
▸ Credentials type
▸ user name & password
▸ ssh
▸ others
▸ ssh
▸ generate ssh key
▸ set user name
▸ set private key path
▸ set passphrase
▸ upload ssh public key to git server
INTEGRATION WITH GITHUB WEB HOOK
▸ Jenkins -> 管理理 Jenkins -> 管理理外掛程式
▸ 可⽤用的 -> Github Integration Plugin 勾選安裝
▸ 建置觸發程序 GitHub hook trigger for GITScm polling 勾選
▸ GitHub repo -> setting -> integration services
▸ add service -> Jenkins (Github plugin)
▸ set up jenkins web hook path 

https://jenkins_domain_name/github_webhook/
▸ active 勾選
▸ 如何驗證測試
▸ push commit 到指定的 branch
▸ 在 job 選單點選 Github Hook Log
SET UP WITH ANDROID
▸ Set up Java
▸ 管理理 Jenkins -> Global Tool Configuration
SET UP WITH ANDROID
▸ Set up gradle
▸ 管理理 Jenkins -> Global Tool Configuration
SET UP WITH ANDROID
▸ Run gradle script
▸ 建置 -> Invoke Gradle Script
▸ 能⽤用的 task 有哪些 ./gradlew tasks
SET UP WITH ANDROID
▸ Set up ANDROID_HOME
▸ 管理理 Jenkins -> 設定系統
▸ 環境變數 ANDROID_HOME
RUN TEST
▸ Unit test report
▸ https://jenkins_url/job/job_name/report_path/
index.html
BUILD
DEPLOYMENT
▸ Fabric beta (internal for QA)
▸ jenkins plugins -> Fabric Beta Publisher
▸ beta api key / build secret
▸ APK path
▸ Notify tester
▸ Beta Group
▸ Release
▸ change log
▸ file
▸ parameter
▸ Google play (for production)
DEPLOYMENT
▸ Google play (for production)
▸ 需要 google play 的 owner 帳號設定
▸ generate credentials
▸ google play console -> api 存取權 (owner)
▸ download credentials json file
▸ create google console user by json file
client_email
▸ 權限設定為發佈者
DEPLOYMENT
▸ Google play (for production)
▸ Install jenkins plugin -> Google Play Android
Publisher Plugin
REPORTING
▸ Lint Report
REPORTING
▸ Unit Test Report
REPORTING
▸ Unit Test Report
REPORTING - SONARQUBE
▸ 程式碼品質分析⼯工具
▸ ⽀支援 20+ 程式語⾔言
▸ Open Source
REPORTING - SONARQUBE
▸ Bugs
▸ Code smells
REPORTING - SONARQUBE
▸ Coverage
▸ Duplications
NOTIFY TO SLACK
▸ Install jenkins plugin -> Global Slack Notifier Plugin
NOTIFY TO SLACK(ADVANCED)
▸ 客製化訊息
NOTIFY TO SLACK(ADVANCED)
▸ Slack Message Builder
ENVIRONMENT VARIABLES
▸ Jenkins 提供環境變數
▸ 整合專案
…下略略
ENVIRONMENT VARIABLES
▸ Gradle 設定
android {
……
defaultConfig {
……
versionCode System.getenv("BUILD_NUMBER") as Integer ?: 0
……
}
}
WHAT’S NEXT
▸ Jenkins pipeline
▸ configuration as code
WHAT’S NEXT
Jenkins
QA
push
developer
Beta
Bug report
Slack
bug/feature/support
PM
feature/support
Github
pull
trigger
WHAT’S NEXT
Jenkin
stage('Preparation') {
steps {
checkout(
[$class : 'GitSCM',
branches : [[name: '*/internal']],
userRemoteConfigs : [[credentialsId: ‘credential_id', url: ‘repo_url’]]
])
}
}
WHAT’S NEXT
Jenkin
stage('Test') {
steps {
script {
try {
sh './gradlew test'
} finally {
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: ‘repo_dir',
reportFiles: 'index.html', reportName: 'Unit Test Report', reportTitles: ''])
}
}
}
}
WHAT’S NEXT
Jenkin
stage('Build') {
steps {
parallel(
alpha: {
sh './gradlew assembleDebug'
},
production: {
sh './gradlew assembleRelease'
}
)
}
}
WHAT’S NEXT
Jenkin
stage('Deploy') {
steps {
parallel(
alpha: {
step([
$class : 'FabricBetaPublisher',
apiKey : “api_key",
apkPath : "app/build/outputs/apk/debug/*.apk",
buildSecret : “build_secret",
notifyTestersType : 'NOTIFY_TESTERS_GROUP',
releaseNotesType : 'RELEASE_NOTES_FROM_CHANGELOG',
testersGroup : "internal",
organization : "pklotcorp",
useAntStyleInclude: true
])
},
production: {
step([])
}
)
}
}
WHAT’S NEXT
Jenkin
stage('Analytics') {
steps {
sh './gradlew lint'
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: 'app/build/reports',
reportFiles: 'lint-results.html', reportName: 'Lint Error Report', reportTitles: ''])
withSonarQubeEnv('SonarQube') {
sh './gradlew clean createDebugCoverageReport jacocoTestReport --info sonarqube'
}
}
}
WHAT’S NEXT
Jenkin
post {
success {
sh 'curl -X POST // see slack api format’
}
failure {
sh ''
}
}
Q&A
REFERENCES
▸ Jenkins Environment Variables: https://goo.gl/
6R5tGi
▸ Slack Message Builder: https://goo.gl/0uKyN5
▸ SonarQube plugin for Kotlin: https://goo.gl/tA8v3F
▸ Install Jenkins on Ubuntu
▸ Jenkins 官網

More Related Content

PDF
COSCUP2017 工程師x小學生 十年碼農養成計畫
PPTX
Continuous integration in games development
PDF
Jenkins X Hands-on - automated CI/CD solution for cloud native applications o...
PPTX
Introduction to Jenkins X
PDF
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
PDF
When Web meet Native App
PPTX
Next-gen DevOps engineering with Docker and Kubernetes by Antons Kranga
PDF
GCE 上搭配 Cloud Storage 建置 Drone CI
COSCUP2017 工程師x小學生 十年碼農養成計畫
Continuous integration in games development
Jenkins X Hands-on - automated CI/CD solution for cloud native applications o...
Introduction to Jenkins X
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
When Web meet Native App
Next-gen DevOps engineering with Docker and Kubernetes by Antons Kranga
GCE 上搭配 Cloud Storage 建置 Drone CI

What's hot (19)

PPTX
CI/CD Pipeline to Deploy and Maintain an OpenStack IaaS Cloud
PPTX
drone continuous Integration
PDF
Welcome to Jenkins
PDF
Евгений Жарков "React Native: Hurdle Race"
PDF
Rise of the Machines - Automate your Development
ODP
A CI/CD Pipeline to Deploy and Maintain OpenStack - cfgmgmtcamp2015
PDF
GDGSCL - Docker a jeho provoz v Heroku a AWS
PDF
Pimp your Continuous Delivery Pipeline with Jenkins workflow (W-JAX 14)
PPTX
Gorush: A push notification server written in Go
PDF
How to successfully migrate to Bazel from Maven or Gradle - Riga Dev Days
PPTX
Jenkins CI presentation
ODP
An Introduction To Jenkins
PPTX
7 Habits of Highly Effective Jenkins Users
PDF
Criando pipelines de entrega contínua multilinguagem com Docker e Jenkins
PPTX
Jenkins for java world
PDF
November 15 cloud bees clusterhq meetup fli, flockerhub, and jenkins
PPTX
Jenkins tutorial
PDF
JCConf 2015 workshop 動手玩 Java 專案建置工具
PDF
Let’s start Continuous Integration with jenkins
CI/CD Pipeline to Deploy and Maintain an OpenStack IaaS Cloud
drone continuous Integration
Welcome to Jenkins
Евгений Жарков "React Native: Hurdle Race"
Rise of the Machines - Automate your Development
A CI/CD Pipeline to Deploy and Maintain OpenStack - cfgmgmtcamp2015
GDGSCL - Docker a jeho provoz v Heroku a AWS
Pimp your Continuous Delivery Pipeline with Jenkins workflow (W-JAX 14)
Gorush: A push notification server written in Go
How to successfully migrate to Bazel from Maven or Gradle - Riga Dev Days
Jenkins CI presentation
An Introduction To Jenkins
7 Habits of Highly Effective Jenkins Users
Criando pipelines de entrega contínua multilinguagem com Docker e Jenkins
Jenkins for java world
November 15 cloud bees clusterhq meetup fli, flockerhub, and jenkins
Jenkins tutorial
JCConf 2015 workshop 動手玩 Java 專案建置工具
Let’s start Continuous Integration with jenkins
Ad

Similar to Jenkins for android developer at TWJUG (20)

PDF
自己的 Jenkins 自己來 for Android developer
PDF
Jenkinsプラグインの作り方
PDF
Continuous Integration using Jenkins with Python
PPTX
Continuous integration jenkins-installation in ec2 instace linux
PPTX
From svn to git
PDF
Jenkins hudsonci-101002103143-phpapp02
PDF
Jenkins CI
PPT
Jenkins CI
PPTX
Moving from Jenkins 1 to 2 declarative pipeline adventures
PDF
Continous Delivering a PHP application
DOCX
Manoj Kolhe - Setup GitHub with Jenkins on Amazon Cloud - End-to-end Automation
PDF
PHP Conf Taiwan 2016 自動化與持續整合實作工作坊
PDF
454976614-Jenkins-Cheat-Sheet-pdf.pdf hoja de ayuda
PPTX
Jenkins CI
PDF
Graduating to Jenkins CI for Ruby(-on-Rails) Teams
PDF
Introduction to jenkins
PPTX
Automate documentation publishing with Jenkins
PDF
Jenkins Days - Workshop - Let's Build a Pipeline - Los Angeles
PDF
Ci system part i
PDF
Travis, Circle そして Jenkins 2.0
自己的 Jenkins 自己來 for Android developer
Jenkinsプラグインの作り方
Continuous Integration using Jenkins with Python
Continuous integration jenkins-installation in ec2 instace linux
From svn to git
Jenkins hudsonci-101002103143-phpapp02
Jenkins CI
Jenkins CI
Moving from Jenkins 1 to 2 declarative pipeline adventures
Continous Delivering a PHP application
Manoj Kolhe - Setup GitHub with Jenkins on Amazon Cloud - End-to-end Automation
PHP Conf Taiwan 2016 自動化與持續整合實作工作坊
454976614-Jenkins-Cheat-Sheet-pdf.pdf hoja de ayuda
Jenkins CI
Graduating to Jenkins CI for Ruby(-on-Rails) Teams
Introduction to jenkins
Automate documentation publishing with Jenkins
Jenkins Days - Workshop - Let's Build a Pipeline - Los Angeles
Ci system part i
Travis, Circle そして Jenkins 2.0
Ad

More from 哲偉 楊 (16)

PDF
Specification unit test by Spek
PDF
Code kata 的自我修煉
PDF
Coding dojo
PDF
輕輕鬆鬆產生 changelog
PDF
Speed up add custom marker on google map
PDF
PDF
從開發到上線的華麗大冒險
PDF
Kotlin初體驗
PDF
Kotlin 初體驗
PDF
Unit test and ui testing with cucumber
PDF
RxJava With retrolambda
PDF
ORMLite Android
PDF
設計師合作經驗分享
PPTX
Dog point
PPTX
PPTX
Hybrid design with bootstrap
Specification unit test by Spek
Code kata 的自我修煉
Coding dojo
輕輕鬆鬆產生 changelog
Speed up add custom marker on google map
從開發到上線的華麗大冒險
Kotlin初體驗
Kotlin 初體驗
Unit test and ui testing with cucumber
RxJava With retrolambda
ORMLite Android
設計師合作經驗分享
Dog point
Hybrid design with bootstrap

Recently uploaded (20)

PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PDF
Categorization of Factors Affecting Classification Algorithms Selection
PPTX
communication and presentation skills 01
PDF
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
PPTX
CyberSecurity Mobile and Wireless Devices
PPTX
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
PPTX
tack Data Structure with Array and Linked List Implementation, Push and Pop O...
PDF
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
PPTX
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
PDF
distributed database system" (DDBS) is often used to refer to both the distri...
PPTX
ASME PCC-02 TRAINING -DESKTOP-NLE5HNP.pptx
PDF
August 2025 - Top 10 Read Articles in Network Security & Its Applications
PDF
Abrasive, erosive and cavitation wear.pdf
PDF
Design Guidelines and solutions for Plastics parts
PDF
Visual Aids for Exploratory Data Analysis.pdf
PDF
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
PDF
Soil Improvement Techniques Note - Rabbi
PDF
Exploratory_Data_Analysis_Fundamentals.pdf
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PPTX
Feature types and data preprocessing steps
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
Categorization of Factors Affecting Classification Algorithms Selection
communication and presentation skills 01
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
CyberSecurity Mobile and Wireless Devices
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
tack Data Structure with Array and Linked List Implementation, Push and Pop O...
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
AUTOMOTIVE ENGINE MANAGEMENT (MECHATRONICS).pptx
distributed database system" (DDBS) is often used to refer to both the distri...
ASME PCC-02 TRAINING -DESKTOP-NLE5HNP.pptx
August 2025 - Top 10 Read Articles in Network Security & Its Applications
Abrasive, erosive and cavitation wear.pdf
Design Guidelines and solutions for Plastics parts
Visual Aids for Exploratory Data Analysis.pdf
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
Soil Improvement Techniques Note - Rabbi
Exploratory_Data_Analysis_Fundamentals.pdf
III.4.1.2_The_Space_Environment.p pdffdf
Feature types and data preprocessing steps

Jenkins for android developer at TWJUG