5

我正在尝试在 AppVeyor 中成功构建后标记存储库。我已阅读以下资源:

但我不知道如何替换 AppVeyor 环境变量。这是我正在使用的 Yaml:

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)

这会导致 AppVeyor 构建日志中出现以下错误

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

鉴于 powershell Add-Content 行应该按照示例工作,您应该如何将变量替换为 git 命令?

4

1 回答 1

7

应该:

- git tag -a release/%APPVEYOR_BUILD_VERSION%
- git push origin release/%APPVEYOR_BUILD_VERSION%
于 2015-05-22T05:28:51.790 回答