使用环境变量

时间:2015-05-21 23:19:03

标签: git environment-variables yaml appveyor

我试图在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命令?

1 个答案:

答案 0 :(得分:7)

应该是:

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