12

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?

Community
  • 1
  • 1
Itai Ganot
  • 5,873
  • 18
  • 56
  • 99

2 Answers2

11

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

Itai Ganot
  • 5,873
  • 18
  • 56
  • 99
  • I'm getting an error here: `java.lang.IllegalArgumentException: The parent does not exist` – Katie Mar 06 '19 at 22:58
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>
ReneA
  • 516
  • 2
  • 7
  • Thanks, do you happen to have reference about archiving the artifacts? I couldn't find an elaborated one... – Itai Ganot Oct 10 '16 at 14:44
  • I added part of the job config. We're not using the pipeline yet, so I cannot help you on the specifics. – ReneA Oct 10 '16 at 15:13
  • 1
    https://github.com/jenkinsci/pipeline-plugin/blob/master/TUTORIAL.md --> Recording Test Results and Artifacts – Bruno Lavit Oct 10 '16 at 15:30