Skip to content

Commit 62c4f66

Browse files
committed
ci: refactor Jenkinsfile.android
1 parent 281d795 commit 62c4f66

File tree

1 file changed

+37
-27
lines changed

1 file changed

+37
-27
lines changed

ci/Jenkinsfile.android

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -46,49 +46,69 @@ pipeline {
4646
}
4747

4848
environment {
49+
/* Architecture */
50+
ARCH = "${params.ARCH}"
51+
52+
/* Build system */
4953
USE_SYSTEM_NIM = "1"
54+
55+
/* Cache directories */
5056
GOCACHE = "/tmp/go-cache"
5157
GOMODCACHE = "/tmp/go-mod-cache"
5258
GOTMPDIR = "/tmp"
53-
STATUS_APK_ARTIFACT = "pkg/Status-tablet-${BUILD_NUMBER}.apk"
54-
PLATFORM = "android/${ARCH}"
59+
NIMCACHE = "/tmp/nim-cache"
60+
61+
/* Platform and artifacts */
62+
PLATFORM = "android/${params.ARCH}"
63+
STATUS_APK_ARTIFACT = "pkg/Status-tablet-${params.ARCH}-${BUILD_NUMBER}.apk"
64+
STATUS_APK = "${WORKSPACE}/mobile/bin/android/${params.ARCH}/qt6/Status-tablet.apk"
65+
66+
/* Android SDK/NDK paths */
67+
ANDROID_SDK_ROOT = "/opt/android-sdk"
68+
ANDROID_NDK_ROOT = "/opt/android-ndk"
69+
70+
/* Qt paths */
71+
QT_BASE_PATH = "/opt/qt/6.9.0"
72+
QT_HOST_PATH = "/opt/qt/6.9.0/gcc_64"
73+
QT_ANDROID_PATH = "${params.ARCH == 'arm64' ? '/opt/qt/6.9.0/android_arm64_v8a' : '/opt/qt/6.9.0/android_x86_64'}"
74+
75+
/* Build configuration */
76+
PKG_CONFIG_PATH = "${params.ARCH == 'arm64' ? '/opt/qt/6.9.0/android_arm64_v8a/lib/pkgconfig' : '/opt/qt/6.9.0/android_x86_64/lib/pkgconfig'}"
77+
PATH = "${params.ARCH == 'arm64' ? '/opt/qt/6.9.0/android_arm64_v8a' : '/opt/qt/6.9.0/android_x86_64'}/bin:/opt/qt/6.9.0/gcc_64/bin:/opt/qt/6.9.0/gcc_64/libexec:${params.ARCH == 'arm64' ? '/opt/qt/6.9.0/android_arm64_v8a' : '/opt/qt/6.9.0/android_x86_64'}/libexec:/opt/android-sdk/emulator:/opt/android-sdk/tools:/opt/android-sdk/tools/bin:/opt/android-sdk/platform-tools:${PATH}"
5578
}
5679

5780
stages {
5881
stage('Prepare') {
5982
steps {
6083
sh 'git submodule update --init --recursive'
61-
script {
62-
def qtPath = getQtAndroidPath(params.ARCH)
63-
env.QT_ANDROID_PATH = qtPath
64-
env.STATUS_APK = "${env.WORKSPACE}/mobile/bin/android/qt6/Status-tablet.apk"
65-
66-
echo "Building for architecture: ${params.ARCH}"
67-
echo "Qt Android path: ${qtPath}"
68-
}
6984
}
7085
}
7186

7287
stage('Build Android APK') {
7388
steps {
7489
sh """
75-
export ARCH="${params.ARCH}"
76-
export PKG_CONFIG_PATH="${env.QT_ANDROID_PATH}/lib/pkgconfig"
77-
export PATH="${env.QT_ANDROID_PATH}/bin:/opt/qt/6.9.0/gcc_64/bin:/opt/qt/6.9.0/gcc_64/libexec:${env.QT_ANDROID_PATH}/libexec:/opt/android-sdk/emulator:/opt/android-sdk/tools:/opt/android-sdk/tools/bin:/opt/android-sdk/platform-tools:${env.PATH}"
90+
set -e
91+
92+
echo "Cleaning previous build..."
7893
make mobile-clean
79-
make -j${utils.getProcCount()} mobile-build V=3 USE_SYSTEM_NIM=1
94+
95+
echo "Building APK..."
96+
make -j${utils.getProcCount()} mobile-build V=3
8097
"""
8198
}
8299
}
83100

84101
stage('Package APK') {
85102
steps {
86103
sh """
104+
set -e
105+
87106
mkdir -p pkg
88107
cp '${env.STATUS_APK}' '${env.STATUS_APK_ARTIFACT}'
89-
ls -la '${env.STATUS_APK_ARTIFACT}'
108+
109+
echo "APK packaged successfully:"
110+
ls -lah '${env.STATUS_APK_ARTIFACT}'
90111
"""
91-
echo "APK packaged: ${env.STATUS_APK_ARTIFACT}"
92112
}
93113
}
94114

@@ -99,6 +119,7 @@ pipeline {
99119
script {
100120
env.PKG_URL = s5cmd.upload(env.STATUS_APK_ARTIFACT)
101121
jenkins.setBuildDesc(APK: env.PKG_URL)
122+
echo "Upload complete: ${env.PKG_URL}"
102123
}
103124
}
104125
}
@@ -117,14 +138,3 @@ pipeline {
117138
cleanup { sh './scripts/clean-git.sh' }
118139
}
119140
}
120-
121-
def getQtAndroidPath(architecture) {
122-
switch(architecture) {
123-
case 'arm64':
124-
return '/opt/qt/6.9.0/android_arm64_v8a'
125-
case 'x86_64':
126-
return '/opt/qt/6.9.0/android_x86_64'
127-
default:
128-
return '/opt/qt/6.9.0/android_arm64_v8a'
129-
}
130-
}

0 commit comments

Comments
 (0)