git - 使用环境变量在 AppVeyor 构建中标记 Git 存储库

标签 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 命令中?

最佳答案

应该是:

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

关于git - 使用环境变量在 AppVeyor 构建中标记 Git 存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30385936/

相关文章:

相当于 p4sync -n 的 git 命令

python - 编辑现有的 yaml 文件但保留原始注释

ruby - 在 Ruby 中,如何在加载 YAML 文档时警告散列中的重复键?

git - 在远程 repo 上删除本地 Git 分支后删除它们

git - 如何设置 gitattributes 来过滤文件的一部分?

Scala sys.env 用于未定义的环境变量

c# - .NET Core 中的环境变量配置

perl - 有没有办法在 Perl 中设置环境变量并将其导出到脚本范围之外?

Linux:更新 yaml 文件中的值

git - 在 git bisect run 期间运行两个命令