How do I embed the build version in an artifact name?

jcw's Avatar


10 Mar, 2014 07:32 AM

I'm attempted to embed the build version in my artifiact name. I'm using the following as the QDeployment Name" but it doesn't seem to be available:

75 Uploading artifact CIVersionTest\bin\CIVersionTest-$(appveyor_build_version).zip (3.3 KB)...Done
76 appveyor_build_version : The term 'appveyor_build_version' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
77 correct and try again.
78 At line:2 char:29
79 + $artifacts["CIVersionTest-$(appveyor_build_version)"] = @{ name = 'CIVersionTest ...
80 + ~~~~~~~~~~~~~~~~~~~~~~
81 + CategoryInfo : ObjectNotFound: (appveyor_build_version:String) [], CommandNotFoundException
82 + FullyQualifiedErrorId : CommandNotFoundException

Is there a way I can accomplish this? I'm attempting to get a zip file named similar to "".

  1. 1 Posted by jcw on 10 Mar, 2014 07:59 AM

    jcw's Avatar

    I should also mention that I tried the following for "Deployment Name":


    But that results in the following error:

    Packaging artifacts...The given path's format is not supported.
  2. 2 Posted by tony on 10 Mar, 2014 12:24 PM

    tony's Avatar

    Try $("CIVersionTest-"+$env:APPVEYOR_BUILD_VERSION) ?

  3. Support Staff 3 Posted by Feodor Fitsner on 10 Mar, 2014 05:47 PM

    Feodor Fitsner's Avatar

    Deployment name is like an "artifact label" used to locate artifact during deployment. To change artifact file name in a cloud storage the only way is to use push artifact command:, for example:

    Push-AppveyorArtifact -FileName "CIVersionTest-$(appveyor_build_version).zip"

    I used double quotes to expand variable in PS string.

  4. 4 Posted by jcw on 10 Mar, 2014 11:55 PM

    jcw's Avatar

    Ah, ok. Well I removed my artifact creation from the UI and am doing it solely through the API now. In case anyone else wants to do the same, I put the following script into Deployment -> "Before deployment script" and now I get an artifact named "":

    function ZipFiles($zipfilename, $sourcedir)
       $compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal
       [System.IO.Compression.ZipFile]::CreateFromDirectory($sourcedir, $zipfilename, $compressionLevel, $false)
    # Step 1 - Sign all output assemblies
    # TODO
    # Step 2 - Zip up output directory (CIVersionTest\bin\Release)
    $binPath = "c:\projects\test1\CIVersionTest\bin\"
    $zipName = "CIVersionTest-v$($env:APPVEYOR_BUILD_VERSION).zip"
    $zipFullPath = "$($binPath)$($zipName)"
    ZipFiles "$($zipFullPath)" "$($binPath)Release" | Out-Null # out-null so that this command doesn't print anything
    # Step 3 - Upload zip file as build artifact
    Push-AppveyorArtifact "$($zipFullPath)" -FileName $zipName
  5. Support Staff 5 Posted by Feodor Fitsner on 10 Mar, 2014 11:59 PM

    Feodor Fitsner's Avatar

    Fantastic, thanks for sharing this!

    Especially nice is ZipFiles function - it demonstrates that .NET 4.5 assemblies can be easily called from PS ;)

    Btw, there is 7z on build servers, so that might be an option too...

  6. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 01:37 AM.

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

Keyboard shortcuts


? 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


06 Jun, 2024 02:12 PM
06 Jun, 2024 03:49 AM
04 Jun, 2024 03:53 AM
30 May, 2024 04:03 PM
27 May, 2024 02:06 AM
20 May, 2024 09:52 PM