Jenkins 压缩调试和发布的 APK,并希望执行 archiveArtifacts。

huangapple go评论61阅读模式
英文:

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
   }
  }
}       

huangapple
  • 本文由 发表于 2023年4月13日 16:07:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76003092.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定