【问题标题】:VSTS: Publish build artifacts to remote repository TFVCVSTS:将构建工件发布到远程存储库 TFVC
【发布时间】:2019-04-03 21:30:23
【问题描述】:

是否可以将来自 Visual Studio 团队服务的构建管道(工件)的输出发布到存储库?我们的 repo 托管在 VSTS 中,并且我们使用 TFVC(团队基金会版本控制来存储我们的代码)。

我使用了开箱即用的复制和发布任务,但它不起作用。

非常感谢您的回复!

【问题讨论】:

  • 为什么您要将二进制文件放入源代码管理中?这被认为是一种不好的做法。如果你解释你的目标是什么,有人可能会推荐一个更好的解决方案。
  • 嗨,唯一的原因是我们只需要将所有二进制文件存储在每个人都可以访问的某个中心位置。所以我的团队负责人建议将它们存储在 VSTS 存储库中。
  • 您可以发布您的工件,然后将它们附加到构建中。或者,您可以将构建推送到包管理提要。

标签: azure-devops azure-pipelines azure-artifacts


【解决方案1】:

正如 Daniel 所说,这被认为是一种不好的做法,但如果您仍然想要它,您可以使用 PowerShell 脚本来实现:

Param(
[string]$tfvcRepoPath
)
$artifactsFolderPath = "$($env:Agent_BuildDirectory)\newCode"
$tempWorkspacePath =  "$($env:Agent_BuildDirectory)\tempWorkspace"

New-Item -Path $artifactsFolderPath-ItemType directory

Copy-Item -Path "$($env:Build_ArtifactStagingDirectory)/*" -Recurse -Destination $artifactsFolderPath

New-Item -Path $tempWorkspacePath -ItemType directory

cd $tempWorkspacePath 

$tfExe = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\tf.exe"

& $tfExe workspace /collection:{TfsCollection} /new "TempWorkspace" /noprompt

& $tfExe workfold "$($tfvcRepoPath)" $tempWorkspacePath 

Copy-Item -Path "$($artifactsFolderPath)/*" -Recurse -Destination $tempWorkspacePath 

& $tfExe add * /recursive /noignore

& $tfExe checkin /recursive /comment:"artficats after build"

& $tfExe workspace /delete /collection:{TfsCollection} "Tempworkspace"

cd c:/
Remove-Item -Path $newCodeFolderPath -Force -Recurse
Remove-Item -Path $tempWorkspacePath -Force -Recurse

更改您安装的 Visual Studio 版本的$tfExe = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\tf.exe"(我使用了 VS 2017 专业版的路径)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-05-30
    • 2018-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-23
    • 1970-01-01
    • 2011-02-28
    相关资源
    最近更新 更多