Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pipeline {
- agent {
- // Run on a build agent where we have the Android SDK installed
- label 'master'
- }
- options {
- // Stop the build early in case of compile or test failures
- skipStagesAfterUnstable()
- }
- stages {
- stage('Compile') {
- environment {
- ANDROID_HOME="/usr/lib/android-sdk/"
- //PATH="${ANDROID_HOME}/emulator:${ANDROID_HOME}/platform-tools:$PATH"
- }
- steps {
- // Compile the app and its dependencies
- sh './gradlew compileDebugSources --scan'
- }
- }
- stage('Lint & Unit Test') {
- parallel {
- //stage('checkStyle') {
- //environment {
- // ANDROID_HOME="/home/jenkins-bot/androis-sdk"
- //PATH="${ANDROID_HOME}/emulator:${ANDROID_HOME}/platform-tools:$PATH"
- //}
- //steps {
- // We use checkstyle gradle plugin to perform this
- // sh './gradlew checkStyle'
- // }
- //}
- stage('Unit Test') {
- environment {
- ANDROID_HOME="/usr/lib/android-sdk/"
- //PATH="${ANDROID_HOME}/emulator:${ANDROID_HOME}/platform-tools:$PATH"
- }
- steps {
- // Execute your Unit Test
- sh './gradlew testDebugUnitTest'
- }
- }
- }
- }
- stage('Build APK') {
- environment {
- ANDROID_HOME="/usr/lib/android-sdk/"
- //PATH="${ANDROID_HOME}/emulator:${ANDROID_HOME}/platform-tools:$PATH"
- }
- steps {
- // Finish building and packaging the APK
- sh './gradlew app:assembleDebug'
- // Archive the APKs so that they can be downloaded from Jenkins
- archiveArtifacts '**/*.apk'
- }
- }
- stage('Static analysis') {
- environment {
- ANDROID_HOME="/usr/lib/android-sdk/"
- //PATH="${ANDROID_HOME}/emulator:${ANDROID_HOME}/platform-tools:$PATH"
- }
- steps {
- // Run Lint and analyse the results
- sh './gradlew lintDebug'
- androidLint pattern: '**/lint-results-*.xml'
- }
- }
- stage('Deploy') {
- environment {
- ANDROID_HOME="/usr/lib/android-sdk/"
- //PATH="${ANDROID_HOME}/emulator:${ANDROID_HOME}/platform-tools:$PATH"
- }
- //when {
- // Only execute this stage when building from the `beta` branch
- // branch 'master'
- //}
- steps {
- // Build the app in release mode, and sign the APK using the environment variables
- sh './gradlew app:assembleRelease'
- // Archive the APKs so that they can be downloaded from Jenkins
- archiveArtifacts '**/*.apk'
- // Upload the APK to Google Play
- //androidApkUpload googleCredentialsId: 'Google Play', apkFilesPattern: '**/*-release.apk', trackName: 'beta'
- }
- post{
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement