How can I check-in files in TFS with azure pipelines

廉价感情. 提交于 2021-02-20 02:45:51

问题


I'm trying to automate a local deployment script that builds a javascript bundle and then, with the help of TFS command line tool, it checks-in the bundle into a TFS repository.

Right now I have the pipeline building the bundle but I still need a last Task that puts the created files into TFS. It is important to note that the TFS is in another project.

Is there a Taks that does check-ins to TFS? If not, what alternatives do I have without using a custom script for that?


回答1:


I wrote a little PowerShell script to do check-in from my build:

$newCodeFolderPath = "$($env:Agent_BuildDirectory)\newCode"
$tempWorkspacePath =  "$($env:Agent_BuildDirectory)\tempWorkspace"

New-Item -Path $newCodeFolderPath -ItemType directory

Copy-Item -Path "/your/fules/you/want/checkin" -Recurse -Destination $newCodeFolderPath 

New-Item -Path $tempWorkspacePath -ItemType directory

cd $tempWorkspacePath 

#For VS 2017 (in other versions the tf.exe location is different)
$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 "{TFS proeject path (where you want to check in)}" $tempWorkspacePath 

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

& $tfExe add * /recursive /noignore

& $tfExe checkin /recursive /comment:"from build"

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

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


来源:https://stackoverflow.com/questions/53766855/how-can-i-check-in-files-in-tfs-with-azure-pipelines

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!