Alexander Martinz | 4bdea57 | 2022-10-17 17:11:59 +0200 | [diff] [blame] | 1 | class Constants { |
| 2 | static final String RELEASE_BRANCH = 'release' |
| 3 | |
| 4 | static final String QA_BUILD = 'Debug' |
| 5 | static final String RELEASE_BUILD = 'Release' |
| 6 | |
| 7 | static final String INTERNAL_TRACK = 'internal' |
| 8 | static final String RELEASE_TRACK = 'release' |
| 9 | } |
| 10 | |
| 11 | def getBuildType() { |
| 12 | switch (env.BRANCH_NAME) { |
| 13 | case Constants.RELEASE_BRANCH: |
| 14 | return Constants.RELEASE_BUILD |
| 15 | default: |
| 16 | return Constants.QA_BUILD |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | def getTrackType() { |
| 21 | switch (env.BRANCH_NAME) { |
| 22 | case Constants.RELEASE_BRANCH: |
| 23 | return Constants.RELEASE_TRACK |
| 24 | default: |
| 25 | return Constants.INTERNAL_TRACK |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | def isDeployCandidate() { |
| 30 | return ("${env.BRANCH_NAME}" =~ /(${RELEASE_BRANCH}|main|next)/) |
| 31 | } |
| 32 | |
| 33 | pipeline { |
| 34 | agent any |
| 35 | |
| 36 | environment { |
| 37 | appName = 'Aperture' |
| 38 | |
| 39 | SIGN_STORE = credentials('sign_store_shift_releasekey') |
| 40 | SIGN_STORE_PASS = credentials('sign_store_pass_shift_releasekey') |
| 41 | SIGN_KEY_ALIAS = credentials('sign_key_alias_shift_releasekey') |
| 42 | SIGN_KEY_PASS = credentials('sign_key_pass_shift_releasekey') |
| 43 | } |
| 44 | |
| 45 | stages { |
| 46 | stage('Build') { |
| 47 | steps { |
| 48 | echo "Building '$appName'" |
| 49 | script { |
| 50 | VARIANT = getBuildType() |
| 51 | sh('./gradlew \ |
| 52 | -Psign_store="$SIGN_STORE" \ |
| 53 | -Psign_store_pass="$SIGN_STORE_PASS" \ |
| 54 | -Psign_key_alias="$SIGN_KEY_ALIAS" \ |
| 55 | -Psign_key_pass="$SIGN_KEY_PASS" ' |
| 56 | + "assemble$VARIANT") |
| 57 | |
| 58 | archiveArtifacts \ |
| 59 | artifacts: 'app/build/outputs/apk/**/*.apk, app/build/outputs/apk/**/*.json', \ |
| 60 | fingerprint: true, \ |
| 61 | followSymlinks: false, \ |
| 62 | onlyIfSuccessful: true |
| 63 | } |
| 64 | cleanWs() |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | post { |
| 70 | success { |
| 71 | mattermostSend \ |
| 72 | color: 'good', \ |
| 73 | message: "SUCCESS -> ${env.JOB_NAME} (#${env.BUILD_NUMBER})\n(<${env.BUILD_URL}|Open>)", \ |
| 74 | text: ':android: :bongo_blob: :blob_dance: :bongo_blob: :android:' |
| 75 | } |
| 76 | failure { |
| 77 | mattermostSend \ |
| 78 | color: 'danger', \ |
| 79 | message: "FAILURE -> ${env.JOB_NAME} (#${env.BUILD_NUMBER})\n(<${env.BUILD_URL}|Open>)", \ |
| 80 | text: ':facepalm: :sarcastic: :dull_: :sarcastic: :facepalm:' |
| 81 | } |
| 82 | } |
| 83 | } |