i am creating YAML pipeline which stored on azure git repo, however i need to checkout TFVC Repo which exist on the same project by referencing as below,
resources:
repositories:
- repository: Shared
name: Playground/Shared
type: tfvc
ref: master #branch name
i know we can checkout azure Git, GitHub, Bitbucket repos. could some one clarify whether we can refer or not.
CodePudding user response:
YAML pipeline does not support TFVC currently.
As workaround you can migrate TFVC to Git.
You can also create a classic UI build pipeline instead of YAML pipeline. TFVC is supported on classic UI pipeline.
Update:
- To bring the code from tfsvc repo into build agent.
you can use TFVC Get items rest api to get the items. Add a script task in your pipeline to call the rest api and save the items in the build agent.
Please check about below example powershell script: To get a Personal access token. Please refer to document here.
$url = "$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_apis/tfvc/items?scopePath=path&recursionLevel=full&api-version=5.1"
$PAT= "Personal access token"
$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($PAT)"))
$result = Invoke-RestMethod -Uri $url -Method Get -Header @{Authorization = "Basic $base64AuthInfo"}
$files= $result.value | where { !$_.isFolder} | select path, url
foreach($file in $files){
$path = "$(System.DefaultWorkingDirectory)\" $file.path.Substring(2)
New-Item -Path $path -ItemType File -Force
Invoke-RestMethod -Uri $file.url -Method get -Header @{Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"} -OutFile $path
}
Above script call the Get Items Api and get the items url and path($files= $result.value | where { !$_.isFolder} | select path, url
)
Then get each item and save to $(System.DefaultWorkingDirectory)
.
For example if my scopePath is $/MyProject/
, then the items will be save to $(System.DefaultWorkingDirectory)/MyProject/