【发布时间】:2016-11-08 17:43:38
【问题描述】:
我正在尝试在 GitLab CI 中设置构建过程。 现在我正在使用带有 Powershell 的 Windows 运行器,我希望构建过程能够自动使用构建的版本号标记提交。
这样做的主要原因是在 Gitlab wiki 中启用自动更改日志生成,不要与通常放在实际项目存储库中的 changelog.md 混淆。
我已经尝试从 Powershell 脚本推送标签,但是推送永远不会完成并无休止地循环,我不清楚为什么会发生这种情况。
脚本调用以下命令
[System.Console]::WriteLine("Tagging git commit (${env:CI_BUILD_REF} ) with tag (v$Version)");
$gitProcess = Start-Process -FilePath "git" -NoNewWindow -Wait -PassThru -ArgumentList "tag -a v$Version ${env:CI_BUILD_REF} -m ${env:CI_BUILD_REF_NAME}_$Version"
if($gitProcess.ExitCode -ne 0)
{
[System.Console]::WriteLine("Git failed to tag the current build");
exit $gitProcess.ExitCode
}
[System.Console]::WriteLine("Pushing tag");
$gitProcess = Start-Process -FilePath "git" -NoNewWindow -Wait -PassThru -ArgumentList "push origin v$Version"
if($gitProcess.ExitCode -ne 0)
{
[System.Console]::WriteLine("Git could not push tags to GitLab");
exit $gitProcess.ExitCode
}
以下是这些行的输出:
Tagging git commit (9b2feb10340c9f8c86ce7c29460e0bfc5dba6f31 ) with tag (v4.1.295.2274)
Pushing tag
进程只是挂在这里,标签永远不会推送或显示在存储库中。
为清楚起见,这是批处理等效项:
git tag -a v%Version% %CI_BUILD_REF% git push origin v%Version%
【问题讨论】:
-
您是否尝试过使用 $env:CI_BUILD_REF?我认为您没有以正确的方式使用 env 变量。而且你不需要做 $() 来使用环境变量。所以没有 {}
-
这些行似乎工作正常,我会将输出添加到帖子中
-
您是否尝试过从 cmd 执行此操作?有用吗?
标签: git powershell tags continuous-integration gitlab