Jenkinsfile 2.3 KB

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