Rest API调用以下载文件/文件夹的特定更改集版本 [英] Rest API Call to download a specific change set version of files/folders

查看:95
本文介绍了Rest API调用以下载文件/文件夹的特定更改集版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试查找针对特定版本修改过的所有文件。这样我们就可以推送这些文件来构建放置位置。这对于不编译代码的团队来说非常容易。我已经使用power
shell编写了一个构建任务来查找所有更改集ID。任何人都可以帮我下载这些更改集中的文件吗?

Hello there, I am trying to find all the files that has been modified for a specific release. So that we can push those files to build drop location. This will makes easy for teams who doesn't do compile the code. I have written a build task using power shell to find all the change sets ID's. Can anyone help me to download the files within those change set?

下面的Get-Changes函数将返回Changeset id的所有列表,寻找下载所有特定版本文件的逻辑建立来源目录。

Below Get-Changes function will return all the list of Changeset id's, looking for a logic to download all the specific version of files to build sources directory.

-Thanks

Hari babu

Hari babu

Param(		
		$sourcefolder,
		$excludedExtensions,
		$usedefaultcreds
    )

function Get-WebClient
{
    param
    (
       $usedefaultcreds
    )

    $webclient = new-object System.Net.WebClient
	
    if ([System.Convert]::ToBoolean($usedefaultcreds) -eq $true)
    {
        Write-Verbose "Using default credentials"
        $webclient.UseDefaultCredentials = $true
    } else {
        Write-Verbose "Using SystemVssConnection personal access token"
        $vssEndPoint = Get-ServiceEndPoint -Name "SystemVssConnection" -Context $distributedTaskContext
        $personalAccessToken = $vssEndpoint.Authorization.Parameters.AccessToken
        $webclient.Headers.Add("Authorization" ,"Bearer $personalAccessToken")
    }
    $webclient.Encoding = [System.Text.Encoding]::UTF8
    $webclient.Headers["Content-Type"] = "application/json"
    $webclient
}
function Get-Changesets
{    param
    (
        $collectionUrl,
        $usedefaultcreds,
		$sourcefolder
    )
    $webclient = Get-WebClient -usedefaultcreds $usedefaultcreds    
    write-verbose "Setting BuildID $buildID with Retention set to $keepForever"
    $uri = "$($collectionUrl)_apis/tfvc/changesets?searchCriteria.itemPath=$($sourcefolder)&api-version=1.0"
	write-verbose "URI = $uri"
	$buildresponse = Invoke-RestMethod -Method GET -UseDefaultCredentials -ContentType application/json -Uri $uri -Body (ConvertTo-Json $body) 	

}

# Output execution parameters.
$VerbosePreference ='Continue' # equiv to -verbose
$collectionUrl = $env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI
$teamproject = $env:SYSTEM_TEAMPROJECT
$releaseid = $env:RELEASE_RELEASEID
$buildid = $env:BUILD_BUILDID
$buildsourcesdir = $env:BUILD_SOURCESDIRECTORY

Get-Changesets -collectionUrl $collectionUrl -usedefaultcreds $usedefaultcreds -sourcefolder $sourcefolder

推荐答案

您好Hari.Babu,

Hi Hari.Babu,

感谢您发布此处。

您可以使用此
获取changeset rest api
以获取更改集中的更改文件。或者您可以使用对象模型api通过变更集ID进行更改。然后下载它们。下面是一个示例,您可以将其转移到构建任务中的powershell脚本。

You could using this get changeset rest api to get changed file in a changeset. Or you could use the object model api to get changes by changeset id. Then download them. Here is an example, you could transfer it to powershell script in your build task.

链接:
https://stackoverflow.com/questions/21545756/get-changeset-and-all-its-changes-on- tfs-using-c-sharp

祝你好运,


这篇关于Rest API调用以下载文件/文件夹的特定更改集版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆