Accessing artifacts from another project

markfinal's Avatar

markfinal

16 May, 2019 10:14 AM

Hi,

I've been trying to download an artifact from a different project in appveyor. I've used the following as reference

https://help.appveyor.com/discussions/questions/19858-accessing-build-artifacts-from-one-project-in-another
https://www.appveyor.com/docs/how-to/download-file/
https://www.appveyor.com/docs/packaging-artifacts/#permalink-to-the-last-successful-build-artifact

but I am still not managing to do it.

The project containing the artifacts is https://ci.appveyor.com/project/markfinal/buildamation, in the master branch, on the Visual Studio 2017 job; there are two artifacts, called bam.zip and bam_docs.zip. It is the former I want. For example, the last successful build artifacts can be seen at https://ci.appveyor.com/project/markfinal/buildamation/builds/23842120/job/20w0coo408s5m28m/artifacts.

I'm trying to download that zip from this other project: https://ci.appveyor.com/project/markfinal/bam-imageformats.
All the builds are currently failing there with my various attempts. The most recent is a 404 error, which corresponds to this line in the .appveyor file:

  - appveyor DownloadFile "https://ci.appveyor.com/api/projects/markfinal/buildamation/artifacts/bam.zip?branch=master&job=Visual%20Studio%202017"

(see https://github.com/markfinal/bam-imageformats/blob/master/.appveyor.yml#L7)

If I put that URL into a web browser, I get this JSON reply:

{"message":"Build job with specified name not found or access denied."}

I'm sure it's something trivial I've missed off, but I've been been able to find the necessary bit of info online.

Can someone help please?

Thanks,
Mark

  1. Support Staff 1 Posted by Owen McDonnell on 16 May, 2019 03:28 PM

    Owen McDonnell's Avatar

    Full name, url encoded, of artifact url is required. Try this...
    "https://ci.appveyor.com/api/projects/markfinal/buildamation/artifacts/bam.zip?branch=master&job=Image%3A%20Visual%20Studio%202017"

  2. 2 Posted by markfinal on 17 May, 2019 01:11 PM

    markfinal's Avatar

    Thanks!

    Your suggestion works when using the URL in a browser.

    But I'm still getting the 404 error when using it in the appveyor script :( See

    https://ci.appveyor.com/project/markfinal/bam-imageformats/builds/24620161

  3. 3 Posted by markfinal on 17 May, 2019 02:44 PM

    markfinal's Avatar

    I also tried wrapping the entire DownloadFile command line in single quotes, as per https://help.appveyor.com/discussions/problems/6991-404-error-when-downloading-artifact-from-build-file, but that still reports the 404 error

    https://ci.appveyor.com/project/markfinal/bam-imageformats/builds/24622583

  4. Support Staff 4 Posted by Owen McDonnell on 17 May, 2019 05:46 PM

    Owen McDonnell's Avatar

    You just need to escape the ampersand(&) in the url with (^) like this,

    appveyor downloadfile 'https://ci.appveyor.com/api/projects/markfinal/buildamation/artifacts/bam.zip?branch=master^&job=Image%3A%20Visual%20Studio%202017'
    
  5. 5 Posted by markfinal on 17 May, 2019 07:46 PM

    markfinal's Avatar

    Thanks.

    I copied that line directly into my .appveyor.yml.
    I no longer get the 404 error (yay).
    But I cannot find where the artifact downloaded to. I have tried a dir command on the current directory.
    I've also tried adding a -Filename option to the download file command to specify where it goes, to no avail (so is now removed).

    Does the file get downloaded somewhere else by default?

    Latest result can be seen here: https://ci.appveyor.com/project/markfinal/bam-imageformats/builds/24629522

  6. 6 Posted by markfinal on 19 May, 2019 06:20 AM

    markfinal's Avatar

    I've been investigating why the URL works in a browser (e.g. Chrome) but not in appveyor scripts.

    Using the developer tools, I figured out that this url

    "https://ci.appveyor.com/api/projects/markfinal/buildamation/artifacts/bam.zip?branch=master&job=Image%3A%20Visual%20Studio%202017"

    is a redirect (302). Would I be right in thinking 'appveyor DownloadFile' doesn't follow redirects?

    So I switched to using curl. I used the default settings (but removed the silent options) from https://www.appveyor.com/docs/how-to/download-file/#curl and enabled redirects (-L). And this command line works from my local computer:

    curl -fL -o bam.zip "https://ci.appveyor.com/api/projects/markfinal/buildamation/artifacts/bam.zip?branch=master&job=Image%3A%20Visual%20Studio%202017"

    But it still fails with a 404 in appveyor.

    If I remove the -f option from curl, I then get JSON downloaded in appveyor containing:

    {"message":"Build job with specified name not found or access denied."}

    (see https://ci.appveyor.com/project/markfinal/bam-imageformats/builds/24647659 for example).

    Again, the real file is downloaded on my local console with that curl command line, since redirects are still enabled.

    Any thoughts on how to proceed?
    Thanks

  7. Support Staff 7 Posted by Owen McDonnell on 20 May, 2019 04:17 AM

    Owen McDonnell's Avatar

    Curl does not follow redirects by default but you can use -L flag to make it do so.
    I believe you're right about the appveyor downloadfile utility not following redirects.

    What worked for me was sticking with powershell like so,

    - ps: Start-FileDownload 'https://ci.appveyor.com/api/projects/markfinal/buildamation/artifacts/bam.zip?branch=master&job=Image%3A%20Visual%20Studio%202017'
    
  8. 8 Posted by markfinal on 20 May, 2019 07:38 AM

    markfinal's Avatar

    That worked!! Great.

    I had tried almost that a few days ago which had not worked, but had double quotes around the URL instead. Single quotes were the key.

    Thanks!

  9. markfinal closed this discussion on 20 May, 2019 07:38 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

 

22 Aug, 2019 08:13 PM
21 Aug, 2019 11:06 PM
21 Aug, 2019 02:08 PM
21 Aug, 2019 01:37 PM
21 Aug, 2019 10:21 AM
21 Aug, 2019 05:56 AM