How can I access artifacts created by Jenkins in the lastSuccessfulBuild through a URL?

纵饮孤独 提交于 2020-06-27 07:10:23

问题


I'm building an Android application using Jenkins pipeline.

When a build finishes successfully, it creates an .apk file.

I want members of the QA team to be able to download this file and test the application before uploading it Google store and so I want these users (which have access to the Jenkins server) to be able to access the artifact through a URL on the Jenkins server as shown in this SO question but for some reason the URL I'm using to try and download the artifact keeps giving me 404 error.

These are the links I'm trying to access but to no avail:

https://company-ci-server.company.net/job/Itai_repos/job/Product-Android/job/develop/lastSuccessfulBuild/build/outputs/apk/Company-production-release.apk

https://company-ci-server.company.net/job/Itai_repos/job/Product-Android/job/develop/lastSuccessfulBuild/artifact/product-production-release.apk

The job is configured as multi-branch which means that Jenkins is watching the project in GitHub, indexes all the branches and whenever a commit happens a job is starting... that is why the link is so long incase you wondered...

So what am I doing wrong? Why can't I access the artifacts through a URL?


回答1:


If it interests anyone, because I'm writing the pipeline myself and I'm not using the GUI to configure my job then I was missing the part of the actual archiving in the pipeline, here's the relevant missing code:

step([$class: 'ArtifactArchiver', artifacts: '**/build/outputs/apk/*.apk', fingerprint: false])

This step tells Jenkins to look for apk files in the given path. Then Jenkins publishes the apk and you can access it through URL:

https://ci-server.company.net/job/Itai_repos/job/Products-Android/job/develop/<BUILD_NUMBER>/artifact/

Thanks




回答2:


As post-build step in your build process Add a task "Archive the artifacts". And specify the files to be made accessible.

On you project dashboard page you will see a link to "Last successful artifacts"

Edit: part of our config added:

<hudson.tasks.ArtifactArchiver>
    <artifacts>
       bin\file1Setup.exe, bin\file2Setup.exe
    </artifacts>
    <allowEmptyArchive>false</allowEmptyArchive>
    <onlyIfSuccessful>false</onlyIfSuccessful>
    <fingerprint>false</fingerprint>
    <defaultExcludes>true</defaultExcludes>
</hudson.tasks.ArtifactArchiver>


来源:https://stackoverflow.com/questions/39960198/how-can-i-access-artifacts-created-by-jenkins-in-the-lastsuccessfulbuild-through

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!