Jenkinsfile 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. pipeline {
  2. agent {
  3. docker {
  4. image 'gitlab-ci-java8'
  5. }
  6. }
  7. stages {
  8. stage('Init') {
  9. steps {
  10. checkout([
  11. $class: 'GitSCM',
  12. branches: [[name: '*/homework_proguard']],
  13. doGenerateSubmoduleConfigurations: false,
  14. extensions: [[$class: 'CleanCheckout']],
  15. submoduleCfg: [],
  16. userRemoteConfigs: [[
  17. url: 'https://github.com/MrOzOn/HealthDiary',
  18. credentialsId: 'CRED_FOR_GITHUB'
  19. ]]])
  20. }
  21. }
  22. stage('Static Analysis') {
  23. failFast true
  24. parallel {
  25. stage('lint') {
  26. steps {
  27. echo './gradlew lintDebug'
  28. }
  29. }
  30. stage('detekt') {
  31. steps {
  32. sh './gradlew detekt'
  33. }
  34. }
  35. }
  36. }
  37. stage('Test') {
  38. steps {
  39. sh './gradlew testDebugUnitTest'
  40. sh './gradlew jacocoTestDebugUnitTestReport'
  41. }
  42. }
  43. stage('Signing APK') {
  44. steps {
  45. prepareProperties()
  46. sh './gradlew assembleRelease'
  47. }
  48. }
  49. }
  50. }
  51. def prepareProperties() {
  52. def propertiesPath = "/.keystore"
  53. sh "mkdir -p ${env.HOME}${propertiesPath}"
  54. withCredentials([file(credentialsId: 'KEYSTORE_PROPERTIES', variable: 'propertiesFile')]) {
  55. sh "cp -f ${propertiesFile} ${env.HOME}${propertiesPath}/keystore.properties"
  56. }
  57. withCredentials([file(credentialsId: 'KEYSTORE_JKS', variable: 'keystore')]) {
  58. sh "cp -f ${keystore} ${env.HOME}${propertiesPath}/learn_otus.jks"
  59. }
  60. }