-
Notifications
You must be signed in to change notification settings - Fork 2
/
Jenkinsfile
56 lines (48 loc) · 2.52 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
@Library(['android-pipeline', 'general-pipeline']) _
node('master') {
withSlack channel: 'jenkins', {
timeout(15) {
stage("init") {
deleteDir()
deviceCount shouldBe: env.ANDROID_DEVICE_COUNT,
action: { devices, message ->
slackMessage channel: 'jenkins', text: message
}
git url: '[email protected]:emartech/android-mobile-engage-sdk.git', branch: 'master'
def testFileCount = sh(returnStdout: true, script: 'find . -name "*Test.java" | wc -l').trim() as Integer
def timeoutRuleCount = sh(returnStdout: true, script: 'grep -r "^\\s*public Timeout globalTimeout = Timeout.seconds(30);" . | wc -l').trim() as Integer
if (testFileCount != timeoutRuleCount) {
error("$testFileCount tests found, but only $timeoutRuleCount timeout rules!")
}
}
withEnv(['DEVELOPMENT_MODE=true']) {
stage("build") {
androidBuild andArchive: '**/*.aar'
}
stage('lint') {
androidLint andArchive: '**/lint-results*.*'
}
stage("unit-test") {
androidTest andArchive: '**/test-results/**/*.xml'
}
stage("instrumentation-test") {
sh './gradlew uninstallDebugAndroidTest'
androidInstrumentationTest withScreenOn: true, withLock: env.ANDROID_DEVICE_FARM_LOCK, withRetryCount: 2, andArchive: '**/outputs/androidTest-results/connected/*.xml'
}
stage('local-maven-deploy') {
sh './gradlew install'
}
}
def version = sh(script: 'git describe', returnStdout: true).trim()
def statusCode = sh returnStdout: true, script: "curl -I https://jcenter.bintray.com/com/emarsys/mobile-engage-sdk/$version/ | head -n 1 | cut -d ' ' -f2".trim()
def releaseExists = "200" == statusCode.trim()
if (version ==~ /\d+\.\d+\.\d+/ && !releaseExists) {
stage('release-bintray') {
slackMessage channel: 'jenkins', text: "Releasing Mobile Engage SDK $version."
sh './gradlew clean build -x lint -x test bintrayUpload'
slackMessage channel: 'jenkins', text: "Mobile Engage SDK $version released to Bintray."
}
}
}
}
}