-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
71 lines (61 loc) · 2.96 KB
/
Jenkinsfile
File metadata and controls
71 lines (61 loc) · 2.96 KB
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
@Library("forgerock-pipeline-libs") _
node('build&&linux') {
checkout scm
stash includes: '**', name: "workspace", useDefaultExcludes: false // if true .git is not included in stash
}
node('gcp-docker-host') {
withPrivateWorkspace() {
def buildImage = docker.build("android:${env.BUILD_ID}", "--label=${env.EXECUTOR_NUMBER} ${env.WORKSPACE}")
buildImage.inside(" --label=${env.EXECUTOR_NUMBER}") {
withCredentials([secrets.androidServicesJson('GOOGLE_SERVICES_FILE'),
secrets.stashUserCredentials("USERNAME", "PASSWORD"),
secrets.androidKeystore("KEYSTORE"),
secrets.androidKeystorePassword("KEYSTORE_PASSWORD")]) {
stage('build') {
sh "ln -s $GOOGLE_SERVICES_FILE app/google-services.json"
sh "echo \"storePassword=${KEYSTORE_PASSWORD}\n" +
"keyAlias=forgerockkey\n" +
"keyPassword=${KEYSTORE_PASSWORD}\n" +
"storeFile=${KEYSTORE}\"" +
" > keystore.properties"
sh "/bin/bash gradlew build -PforgerockUser=${env.USERNAME} -PforgerockPassword=${env.PASSWORD}"
archiveArtifacts artifacts: 'app/build/reports/**', fingerprint: true
}
if (!isPR()) {
// archive the apk
archiveArtifacts 'app/build/outputs/apk/release/app-release.apk'
// Temporally disabling the apk upload, the current version of Google Play Android Publisher plugin is using v2 of the Google API,
// which is not supported by Google anymore.
//
// stage('upload') {
// androidApkUpload apkFilesPattern: 'app/build/outputs/apk/release/app-release.apk', googleCredentialsId: "${secrets.googlePlayAndroidDeveloperId()}", trackName: 'alpha'
//}
}
}
}
}
}
private def withPrivateWorkspace(process) {
ws("workspace/${generatePrefix()}") {
try {
unstash "workspace"
process()
} finally {
try {
identifier = "label=${env.EXECUTOR_NUMBER}"
sh "docker images --filter ${identifier}"
sh "docker image prune -a --force --filter ${identifier}"
sh "docker images --filter ${identifier}"
sh "docker ps --filter ${identifier}"
sh "docker container prune --force --filter ${identifier}"
sh "docker ps --filter ${identifier}"
cleanWs()
} catch (exception) {
echo "Failed to prune - ${exception.getMessage()}"
}
}
}
}
private String generatePrefix() {
return "android-${env.BUILD_NUMBER}-${env.EXECUTOR_NUMBER}-${env.STAGE_NAME}-${System.currentTimeMillis()}"
}