提交jenkins自动化流水线

This commit is contained in:
Home
2026-03-29 01:25:14 +08:00
parent 1e37aa8ea2
commit 6431730d44
2 changed files with 23 additions and 3 deletions
+2 -2
View File
@@ -4,5 +4,5 @@
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Mon Jul 14 18:35:19 CST 2025
sdk.dir=C\:\\Users\\1\\AppData\\Local\\Android\\Sdk
#Sun Mar 29 00:53:29 CST 2026
sdk.dir=C\:\\Users\\Administrator\\AppData\\Local\\Android\\Sdk
Vendored
+21 -1
View File
@@ -7,7 +7,7 @@ pipeline {
UNIAPP_APP_ID = '__UNI__EDE0E52'
ANDROID_ASSETS_DIR = "Android/simpleDemo/src/main/assets/apps/${UNIAPP_APP_ID}/www"
// Android 构建环境
ANDROID_HOME = '/usr/local/android-sdk' // 你的 Jenkins 服务器 SDK 路径
ANDROID_SDK = '/opt/android-sdk' // 安卓 SDK 路径
GRADLE_OPTS = '-Dorg.gradle.daemon=false -Dorg.gradle.parallel=true'
}
stages {
@@ -51,6 +51,26 @@ pipeline {
echo "✅ 资源复制完成"
}
}
// ====================== 构建 APK ======================
stage('配置SDK & 赋予权限 & 编译Android') {
steps {
// 1. 生成 local.properties 指定 SDK 路径
sh "echo 'sdk.dir=${ANDROID_SDK}' > Android/local.properties"
// 2. 直接给 gradlew 加权限(不进入目录)
sh "chmod +x Android/gradlew"
// 3. 直接执行编译(核心:Android/gradlew
sh "Android/gradlew assembleRelease --offline -g ${WORKSPACE}/gradle-home -p Android"
}
}
// stage('查看APK & 归档') {
// steps {
// sh "ls -lh Android/app/build/outputs/apk/release/"
// archiveArtifacts artifacts: 'Android/app/build/outputs/apk/release/*.apk', fingerprint: true
// }
// }
}