VSTS:将构建工件发布到远程存储库TFVC

时间:2018-10-30 18:54:13

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

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

我已经使用了开箱即用的复制和发布任务,但是没有用。

非常感谢您的答复!

1 个答案:

答案 0 :(得分:1)

就像丹尼尔说的那样,这被认为是不好的做法,但是如果您仍然希望这样做,可以使用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 Professional版本的路径)。

相关问题