Install Jenkins
Open Terminal and type below commands:
wget -q -O - https://jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add - sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list' sudo apt-get update sudo apt-get install jenkins
Open browser and entry Jenkins page with below address:
Install Plugins
- Visit Manage Jenkins -> Manage Plugins -> Available
- Check the following plugins :
Gradle Plugin、Git Plugin、Git Client Plugin、Bitbucket Plugin
- Click Install without restart
Configuring Global Security
- Visit Manage Jenkins -> Configure Global Security
- Check Enable security
- Check Jenkins' own user database in Access Control
- Uncheck Allow users to sign up
- Check Matrix-based security in Authorization
- Press Apply
Configuring System
- Visit Manage Jenkins -> Configure System
- Go to Environment variables
Type ANDROID_HOME with name and SDK location with value
/opt/Android/sdk
Extended Email Notification
- Type
smtp.gmail.com
into SMTP Server field - Check Add 'Precedence: bulk' Email Header
- Type your email address into Default Recipients field
- Type
E-mail Notification
- Type
smtp.gmail.com
into SMTP Server field - Check Use SMTP Authentication field
- Type your email address and password into username and password fields
- Check Use SSL
- SMTP Port is 465
- Type
New Item
- Press New Item
- Type project name
- Select Free-style project
- Select Git in Source Code Management
- Type Repository URL with Bitbucket
- Add and select credentials
Kind is Username with password; Type username、password then save it
- Press Add build step at Build and select Invoke Gradle script
- Select Use Gradle Wrapper
- Type clean build to Tasks
- Check From Root Build Script Dir
- Press Add post-build action to add Archive the artifacts and E-mail Notification in Post-build Actions
- Type
**/*.apk
into Files to archive in Post-build Actions - Type our mail address to Recipients in E-mail Notification*
Configuring Android Studio Project
- Set the Android SDK path in local.properties file
sdk.dir=/opt/android-sdk-linux
- Remove the NDK path (We still not install it.)
- Make sure it can auto sign our APK
Commit Android Project To Bitbucket
Use SourceTree to help us.
Build Android Project with Jenkins
- Entry our Jenkins project
- Press Build Now