【问题标题】:How to clone code from multiple sources in TFS 2017?如何在 TFS 2017 中从多个来源克隆代码?
【发布时间】:2020-10-07 15:00:01
【问题描述】:

我的代码在 TFS 存储库中,但由于某些原因,Sharepoint/MS Teams 中的文件很少,我们如何从构建定义中的两个源中克隆代码。

Get Sources 任务是克隆指定 TFS 存储库的默认任务,有没有办法添加或编辑此任务以同时从 Sharepoint 克隆代码。

【问题讨论】:

    标签: tfs build azure-devops azure-pipelines tfsbuild


    【解决方案1】:

    您无法编辑 Get Sources 任务以从 sharepoint 克隆代码。

    但是,您可以使用 powershell task 从共享点下载文件。

    例如,在管道中添加一个 powershell 任务以运行以下内联脚本:

    使用 WebClient

    $SharePointFile = "https://the.server/path/to/the/file.txt"
    $Path = "$(Build.SourcesDirectory)\file.txt"
    
    #User Information
    $Username = "userName"
    $Password = "password"
    
    #Download Files
    $client = New-Object System.Net.WebClient
    $client.Credentials = New-Object System.Net.Networkcredential($UserName, $Password)
    $client.DownloadFile($SharePoint, $Path)
    $client.Dispose()
    

    使用 Invoke-WebRequest

    $User = "userName"
    $PWord = ConvertTo-SecureString -String "password" -AsPlainText -Force
    $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord
    
    $url = 'https://the.server/path/to/the/file.txt'
    $outfile = "$(Build.SourcesDirectory)\file.txt"
    Invoke-WebRequest -Uri $url -OutFile $outfile -Credential $Credential 
    

    以上脚本会将文件从您的共享点服务器下载到代理计算机上的源代码文件夹$(Build.SourcesDirectory)(即c:\agent_work\1\s

    您也可以使用SharePoint Pnp PowerShell Framework 下载 powershell 任务中的文件。请参阅此博客中的 example

    【讨论】:

      猜你喜欢
      • 2019-10-22
      • 2019-05-24
      • 1970-01-01
      • 2012-06-18
      • 1970-01-01
      • 2016-02-14
      • 1970-01-01
      • 2018-12-11
      • 2020-05-11
      相关资源
      最近更新 更多