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?
By default, Jenkins archives artifacts generated by the build. These artifacts are stored in the JENKINS_HOME directory with all other elements such as job configuration files.
In the bottom right of each page Jenkins has a link to their REST API. This link will appear on every page of Jenkins and points you to an API output for the exact page you are browsing. That should provide some understanding about how to build the API URLs.
For a locally hosted Jenkins server, the URL would be: http://localhost:8080/env-vars.html. The easiest way to see how these Jenkins environment variables work is to create a freestyle job, echo each entry in the list and see the value Jenkins assigns to each property.
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>
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With