Advertisement
Guest User

Untitled

a guest
Nov 8th, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. pipeline {
  2. agent {
  3. // Run on a build agent where we have the Android SDK installed
  4. label 'master'
  5. }
  6. options {
  7. // Stop the build early in case of compile or test failures
  8. skipStagesAfterUnstable()
  9. }
  10. stages {
  11. stage('Compile') {
  12. environment {
  13. ANDROID_HOME="/usr/lib/android-sdk/"
  14. //PATH="${ANDROID_HOME}/emulator:${ANDROID_HOME}/platform-tools:$PATH"
  15. }
  16. steps {
  17. // Compile the app and its dependencies
  18. sh './gradlew compileDebugSources --scan'
  19.  
  20. }
  21. }
  22. stage('Lint & Unit Test') {
  23. parallel {
  24. //stage('checkStyle') {
  25. //environment {
  26. // ANDROID_HOME="/home/jenkins-bot/androis-sdk"
  27. //PATH="${ANDROID_HOME}/emulator:${ANDROID_HOME}/platform-tools:$PATH"
  28. //}
  29. //steps {
  30. // We use checkstyle gradle plugin to perform this
  31. // sh './gradlew checkStyle'
  32. // }
  33. //}
  34.  
  35. stage('Unit Test') {
  36. environment {
  37. ANDROID_HOME="/usr/lib/android-sdk/"
  38. //PATH="${ANDROID_HOME}/emulator:${ANDROID_HOME}/platform-tools:$PATH"
  39. }
  40. steps {
  41. // Execute your Unit Test
  42. sh './gradlew testDebugUnitTest'
  43. }
  44. }
  45. }
  46. }
  47. stage('Build APK') {
  48. environment {
  49. ANDROID_HOME="/usr/lib/android-sdk/"
  50. //PATH="${ANDROID_HOME}/emulator:${ANDROID_HOME}/platform-tools:$PATH"
  51. }
  52. steps {
  53. // Finish building and packaging the APK
  54. sh './gradlew app:assembleDebug'
  55.  
  56. // Archive the APKs so that they can be downloaded from Jenkins
  57. archiveArtifacts '**/*.apk'
  58. }
  59. }
  60. stage('Static analysis') {
  61. environment {
  62. ANDROID_HOME="/usr/lib/android-sdk/"
  63. //PATH="${ANDROID_HOME}/emulator:${ANDROID_HOME}/platform-tools:$PATH"
  64. }
  65. steps {
  66. // Run Lint and analyse the results
  67. sh './gradlew lintDebug'
  68. androidLint pattern: '**/lint-results-*.xml'
  69. }
  70. }
  71. stage('Deploy') {
  72. environment {
  73. ANDROID_HOME="/usr/lib/android-sdk/"
  74. //PATH="${ANDROID_HOME}/emulator:${ANDROID_HOME}/platform-tools:$PATH"
  75. }
  76. //when {
  77. // Only execute this stage when building from the `beta` branch
  78. // branch 'master'
  79. //}
  80. steps {
  81. // Build the app in release mode, and sign the APK using the environment variables
  82. sh './gradlew app:assembleRelease'
  83.  
  84. // Archive the APKs so that they can be downloaded from Jenkins
  85. archiveArtifacts '**/*.apk'
  86.  
  87. // Upload the APK to Google Play
  88. //androidApkUpload googleCredentialsId: 'Google Play', apkFilesPattern: '**/*-release.apk', trackName: 'beta'
  89. }
  90. post{
  91.  
  92. }
  93. }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement