我正在尝试在GitLab CI中设置构建流程。
目前我正在使用Windows运行程序和Powershell,并希望构建流程能够自动为提交打上版本号标签。
这样做的主要原因是为了启用Gitlab Wiki的自动变更日志生成功能,不要与通常放置在实际项目存储库中的changelog.md混淆。
我曾经尝试过从Powershell脚本中推送标签,但该推送从未完成并且无休止地循环,我不清楚为什么会发生这种情况。
该脚本调用以下命令。
这些代码的输出如下:
这样做的主要原因是为了启用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%