英文:
Jenkins zip debug and release APKs and want to do archiveArtifacts
问题
在我的项目中,我们有两个构建变体(假设为paidA和paidB)。组装应用程序将生成4个APK文件,它们分别是(paidA调试和发布)和(paidB调试和发布)。我需要将这四个APK文件打包。我尝试了以下代码,但失败了。
sh "zip -r builds.zip . -i builds"
sh "cd ${env.WORKSPACE}"
echo "${env.WORKSPACE}"
archiveArtifacts artifacts: "builds.zip", onlyIfSuccessful: true
请建议一下如何解决这个问题。
英文:
in my project we have 2 build variants (assume) paidA & paidB. assemble the app will generate 4 apks which are (paidA debug and release) and (paidB Debug and release).
I need to artifact all these four apks. I tried with the following code but it fails
sh "zip -r builds.zip . -i builds"
sh "cd ${env.WORKSPACE}"
echo "${env.WORKSPACE}"
archiveArtifacts artifacts: "builds.zip", onlyIfSuccessful: true
Kindly advice a bit to get rid off this.
答案1
得分: 0
以下是已翻译的部分:
这是我的工作解决方案。请确保路径与您的项目相符。
stage('Artifact') {
steps {
script {
sh "mkdir -p ${env.WORKSPACE}/builds"
sh "cp app/build/outputs/apk///*.apk ${env.WORKSPACE}/builds"
sh "cd ${env.WORKSPACE}/builds"
zip zipFile: 'apks.zip', archive: false, dir:
"${env.WORKSPACE}/builds"
archiveArtifacts artifacts: '${env.WORKSPACE}/builds, apks.zip',
onlyIfSuccessful: true
}
}
}
英文:
Here is my working solution. Kindly make sure the path as per your project.
stage('Artifact') {
steps {
script {
sh "mkdir -p ${env.WORKSPACE}/builds"
sh "cp app/build/outputs/apk/*/*/*.apk ${env.WORKSPACE}/builds"
sh "cd ${env.WORKSPACE}/builds"
zip zipFile: 'apks.zip', archive: false, dir:
"${env.WORKSPACE}/builds"
archiveArtifacts artifacts: '${env.WORKSPACE}/builds, apks.zip',
onlyIfSuccessful: true
}
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论