Using {version} in cmd build_before

Christian's Avatar

Christian

05 Nov, 2015 06:53 AM

Hi,

I have a simple script which updates version information in some of my artifacts, and which I can execute locally. Now, I'd like to execute it within the build_before script as well, passing the {version} variable to it. That's where I'm stuck. I've tried

- cmd: >-
    cd MyDir

    SetVersion {version}

    cd ..

as well as

- cmd: >-
    cd MyDir

    SetVersion $env:APPVEYOR_BUILD_VERSION

    cd ..

Both don't work. What's the way to go here? Google didn't help...

Thanks in advance,
Christian

  1. Support Staff 1 Posted by Feodor Fitsner on 05 Nov, 2015 07:01 AM

    Feodor Fitsner's Avatar

    Try:

    - cmd: >- 
        cd MyDir
    
        SetVersion %APPVEYOR_BUILD_VERSION%
    
        cd ..
    
  2. 2 Posted by Christian on 05 Nov, 2015 07:06 AM

    Christian's Avatar

    Thanks! That was fast :-)

  3. 3 Posted by Christian on 05 Nov, 2015 09:16 AM

    Christian's Avatar

    I have a follow-up question: My build still fails, output:

    cd MyDir
    SetVersion %APPVEYOR_BUILD_VERSION%
    Usage : SetVersion <version>, where <version> should be <major>.<minor>.<revision>.<build>
    Example: SetVersion 1.0.1.42
    cd ..

    My batch script (which is only a frontend for a powershell script) looks as follows:

    @echo off

    if "%1"=="" goto _USAGE

    PowerShell.exe -ExecutionPolicy Bypass -File "SetVersion.ps1" -version "%1"

    :_USAGE
    echo Usage : SetVersion ^<version^>, where ^<version^> should be ^<major^>.^<minor^>.^<revision^>.^<build^>
    echo Example: SetVersion 1.0.1.42

    If I run the script locally, i.e. "SetVersion 0.2.0.42", it works fine. Does this mean that the binding of the version to the environment variable APPVEYOR_BUILD_VERSION has failed for some reason?

    On a side note, I have noticed that in general, the build output does not show the actual values which are substituted for the AppVeyor env variables, but the env variables themselves (i.e., as can be seen within the appveyor.yml config file. Is this on purpose? I guess that I would prefer to see my commands as actually executed (i.e., with the substituted values), but I might very well not see the reasons for not doing so...

    Thanks again,
    Christian

  4. 4 Posted by Christian on 05 Nov, 2015 06:45 PM

    Christian's Avatar

    Stupid me... Of course, the script runs through the usage section, no matter if a value is passed or not - there's a "goto :eof" missing :-(

  5. Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 02:01 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