forked from badoo/mopub-android-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
72 lines (71 loc) · 4.42 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env groovy
def androidAutomationProjectName = "mopub-android-automation"
pipeline {
agent any
environment {
ANDROID_HOME = '/Users/jenkins/Library/Android/sdk'
projectName = """${
sh(script: 'IFS="/" read -ra TOKENS <<< "${JOB_NAME}"; echo ${TOKENS[0]}', returnStdout: true).trim()
}"""
}
stages {
stage('Tests') {
steps {
script {
PARSED_JOB_NAME = URLDecoder.decode(env.JOB_NAME, 'UTF-8')
if (projectName == androidAutomationProjectName) {
stage('Internal Android automation tests') {
echo "Internal Automation Tests are running - ${PARSED_JOB_NAME}"
sh '''
#!/bin/bash
chmod +x scripts/private/android.sh
scripts/private/android.sh
'''
}
stage('External Android automation tests') {
echo "External Automation Tests are running - ${PARSED_JOB_NAME}"
sh '''
#!/bin/bash
chmod +x scripts/private/androidRT.sh
scripts/private/androidRT.sh
'''
}
} else {
stage('Smoke tests') {
echo "Smoke Tests are running - ${PARSED_JOB_NAME}"
sh '''
#!/bin/bash
./gradlew clean build
'''
}
stage('Sign apk') {
sh '$ANDROID_HOME/build-tools/29.0.2/zipalign -v -p 4 mopub-sample/build/outputs/apk/external/release/mopub-sample-external-release-unsigned.apk mopub-sample/build/outputs/apk/external/release/mopub-sample-external-release-unsigned-aligned.apk'
if (fileExists('mopub-sample/build/outputs/apk/internal/release/mopub-sample-internal-release-unsigned.apk')) {
sh '$ANDROID_HOME/build-tools/29.0.2/zipalign -v -p 4 mopub-sample/build/outputs/apk/internal/release/mopub-sample-internal-release-unsigned.apk mopub-sample/build/outputs/apk/internal/release/mopub-sample-internal-release-unsigned-aligned.apk'
}
withCredentials([string(credentialsId: 'android_store_key_pass', variable: 'JKS_PASS')]) {
sh '$ANDROID_HOME/build-tools/29.0.2/apksigner sign --ks ~/google_play_key.jks --ks-pass pass:$JKS_PASS --out mopub-sample/build/outputs/apk/external/release/mopub-sample-external-release-signed.apk mopub-sample/build/outputs/apk/external/release/mopub-sample-external-release-unsigned-aligned.apk'
if (fileExists('mopub-sample/build/outputs/apk/internal/release/mopub-sample-internal-release-unsigned-aligned.apk')) {
sh '$ANDROID_HOME/build-tools/29.0.2/apksigner sign --ks ~/google_play_key.jks --ks-pass pass:$JKS_PASS --out mopub-sample/build/outputs/apk/internal/release/mopub-sample-internal-release-signed.apk mopub-sample/build/outputs/apk/internal/release/mopub-sample-internal-release-unsigned-aligned.apk'
}
}
}
stage('Archive') {
archiveArtifacts artifacts: 'mopub-sample/build/outputs/**/*.apk', excludes: 'mopub-sample/build/outputs/**/*unsigned.apk, mopub-sample/build/outputs/**/*aligned.apk', onlyIfSuccessful: true
archiveArtifacts artifacts: 'mopub-sdk/build/outputs/aar/mopub-sdk-*.aar', onlyIfSuccessful: true
archiveArtifacts artifacts: 'mopub-sdk/mopub-sdk-*/build/outputs/aar/mopub-sdk-*.aar', onlyIfSuccessful: true
}
}
}
}
}
}
post {
fixed {
slackSend color: 'GREEN', message: "<${env.BUILD_URL}|${PARSED_JOB_NAME} #${env.BUILD_NUMBER}> has succeeded."
}
failure {
slackSend color: 'RED', message: "Attention @here <${env.BUILD_URL}|${PARSED_JOB_NAME} #${env.BUILD_NUMBER}> has failed."
}
}
}