Search code examples
gitenvironment-variablesyamlappveyor

Label Git repository in AppVeyor build using environment variable


I am trying to label a repository after a successful build in AppVeyor. I have read the following resources:

But I don't know how to substitute in an AppVeyor environment variable. Here is the Yaml that I am using:

on_success:
  - git config --global credential.helper store
  - ps: Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:access_token):x-oauth-basic@github.com`n"
  - git tag -a release/$($env:APPVEYOR_BUILD_VERSION)
  - git push origin release/$($env:APPVEYOR_BUILD_VERSION)

This results in the following error in the AppVeyor build log

git config --global credential.helper store
Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:access_token):x-oauth-basic@github.com`n"
git tag -a release/$($env:APPVEYOR_BUILD_VERSION)
fatal: 'release/$($env:APPVEYOR_BUILD_VERSION)' is not a valid tag name.
Command exited with code 128

Given that the powershell Add-Content line is supposed to work as per the example how are you supposed to substitute variables into the git commands?


Solution

  • Should be:

    - git tag -a release/%APPVEYOR_BUILD_VERSION%
    - git push origin release/%APPVEYOR_BUILD_VERSION%