Accessing build artifacts from one project in another

Volker Enderlein's Avatar

Volker Enderlein

23 Apr, 2018 09:13 PM

Hi,
I started using AppVeyor a week ago and was really excited. Got my jobs up and running. But when using more than one configuration for a project I stumbled across the question how to access an artifact from another project on the same account.
So my base project has following appveyor.yml:

version: 1.3.0-{branch}-ci-{build}
install:
  - sh: sudo apt-get install freeglut3-dev -y
branches:
  only:
  - AppVeyorCI
os:
  - Visual Studio 2015
platform:
  - x64
configuration:
  - Debug
  - Release
before_build:
  - cmd: cmake -H. -Bbuild -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=%APPVEYOR_BUILD_FOLDER%\installdir
build_script:
  - cmd: cmake --build build --target INSTALL --config %CONFIGURATION% -- /nologo /verbosity:minimal /maxcpucount
after_build:
  - cd %APPVEYOR_BUILD_FOLDER%
  - set BUILD_ARCHIVE=%APPVEYOR_PROJECT_NAME%-%CONFIGURATION%.zip
  - cmd: 7z a %BUILD_ARCHIVE% installdir
  - appveyor PushArtifact %BUILD_ARCHIVE%
artifacts:
  - path: '*.zip'

in my dependent project I try to download the artifact the following way:

version: 4.0.0-{branch}-ci-{build}
install:
  - appveyor DownloadFile https://ci.appveyor.com/api/projects/<accountname>/<projectname>/artifacts/<projectname>-Debug.zip?branch=AppVeyorCI&job=Configuration%3A+Debug
  - appveyor DownloadFile https://ci.appveyor.com/api/projects/<accountname>/<projectname>/artifacts/<projectname>-Release.zip?branch=AppVeyorCI&job=Configuration%3A+Release
  - 7z x <projectname>-Debug.zip -oc:\projects
  - 7z x <projectname>-Release.zip -oc:\projects

According to the docs this should work but I`m constantly getting the error:

Error downloading remote file: One or more errors occurred.
Inner Exception: Remote server returned 400: Bad Request
'job' is not recognized as an internal or external command,
operable program or batch file.
Command exited with code 9009

I can view the artifacts in the GUI, they are present, but I cannot access them.
Having only one configuration and omitting the job parameter works flawlessly.
Obviously i`m doing something wrong but I did not manage to find my error and got stuck here.

Thanks in advance

Cheers Volker

  1. Support Staff 1 Posted by Ilya Finkelshte... on 24 Apr, 2018 02:04 AM

    Ilya Finkelshteyn's Avatar

    You need to wrap URL in double quotes.

  2. 2 Posted by Volker Enderlei... on 25 Apr, 2018 08:21 AM

    Volker Enderlein's Avatar

    Thank you Ilya,

    that fixed the first part, but I am still unable to download the artifacts using the command `appveyor DownloadFile <link>` or `curl -L -o<name> <link>` in the appveyor.yml. It always gives a 404 Error.

    Cheers Volker

  3. 3 Posted by Volker Enderlei... on 25 Apr, 2018 08:38 AM

    Volker Enderlein's Avatar

    Forgot to mention:

    if I copy the link to the browser the download immediately starts. So it is still mysterious to me.

    Cheers Volker

  4. Support Staff 4 Posted by Ilya Finkelshte... on 25 Apr, 2018 03:46 PM

    Ilya Finkelshteyn's Avatar

    Try to run the same command in PowerShell (- ps: prefix), or even use Start-FileDownload cmdlet. It is simpler to run command containing all those special symbols in PowerShell.

  5. 5 Posted by Volker Enderlei... on 26 Apr, 2018 10:30 PM

    Volker Enderlein's Avatar

    As the job name can be arbitrarily complex for build matrices I came up with the following solution:

      - sh: DOWNLOAD_FILE=<project>-1.3.0-$COMPILER_ID-$CMAKE_PLATFORM-$CMAKE_CONFIGURATION.tar.gz
      - sh: DOWNLOAD_ADDRESS=https://ci.appveyor.com/api/projects/<account>/<project>/artifacts/$DOWNLOAD_FILE
      - sh: 'curl -fsSL -G -v -o "$DOWNLOAD_FILE" "$DOWNLOAD_ADDRESS" --data-urlencode "branch=AppVeyorCI" --data-urlencode "job=Environment: APPVEYOR_BUILD_WORKER_IMAGE=$APPVEYOR_BUILD_WORKER_IMAGE, CMAKE_GENERATOR=$CMAKE_GENERATOR, configuration=$CMAKE_CONFIGURATION, platform=$CMAKE_PLATFORM, CMAKE_CONFIGURATION=$CMAKE_CONFIGURATION, CMAKE_PLATFORM=$CMAKE_PLATFORM, CMAKE_ARCH_FLAGS=$CMAKE_ARCH_FLAGS, COMPILER_ID=$COMPILER_ID"'
    

    You might feel free to add this note as example to the download file section of the documentation.

    Thank you again Ilya for your support.

  6. Support Staff 6 Posted by Ilya Finkelshte... on 04 May, 2018 05:33 PM

    Ilya Finkelshteyn's Avatar

    @Volker thanks a lot for sharing!

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

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