获取 Azure DevOps 管道中的具体任务版本

mic*_*cer 1 azure azure-data-factory azure-devops azure-pipelines

这是我的任务代码:

- task: PublishADFTask@1
  displayName: 'Publish Datafactory'
  inputs:
       // inputs there
Run Code Online (Sandbox Code Playgroud)

但最新版本有一个bug 1.*

这是在 azure devops yaml 管道中使用先前任务版本的方法吗?

我试过:

- task: PublishADFTask@1.27.1315
  displayName: 'Publish Datafactory'
  inputs:
       // inputs there
Run Code Online (Sandbox Code Playgroud)

但这不起作用

jes*_*ing 5

只要组织中安装了旧版本,就应该可以使用tfx build tasks upload如果需要,您可以使用powershell 脚本将旧版本强制上传到组织中。如果有人卸载并重新安装扩展以尝试解决问题,则旧版本可能会丢失。

要上传旧版本的任务,首先请确保您拥有已知良好的任务版本的 zip 文件或该任务可用的文件夹,然后运行:

# use node 16 or better
npm install -g tfx-cli

# for an extracted task folder
tfx build tasks upload --task-path .\1.27.1315

# for a zipped up task
tfx build tasks upload --task-zip-path .\mytask.zip
Run Code Online (Sandbox Code Playgroud)

或者使用这个 PowerShell 片段:

"Installing task '$($Task.Name)' version '$($Task.Version)' id '$($Task.Id)'."
$url = "$($CollectionUrl.TrimEnd('/'))/_apis/distributedtask/tasks/$($Task.Id)/?overwrite=false&api-version=2.0"

[byte[]]$bytes = [System.IO.File]::ReadAllBytes((Get-Item -LiteralPath $TaskZip).FullName)

Invoke-RestMethod -Uri $url -Method Put -Body $bytes -UseDefaultCredentials -ContentType 'application/octet-stream' -Headers @{
    'Authorization' = "Basic $([System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(":$Pat")))"
    'X-TFS-FedAuthRedirect' = 'Suppress'
    'Content-Range' = "bytes 0-$($bytes.Length - 1)/$($bytes.Length)"
}
Run Code Online (Sandbox Code Playgroud)

我在一篇博客文章中列出了整个过程

如果需要,请直接从 Azure DevOps Marketplace 下载旧版本的任务。以下命令应将所有可用版本转储到输出。找到您想要的版本并查找 asset of typeMicrosoft.VisualStudio.Services.VSIXPackage以获取旧版本扩展的下载 url:

tfx extension show --publisher SQLPlayer --extension-id DataFactoryTools

{
    "publisher": {
        "publisherId": "6e2d04c5-e827-4358-a426-97b85f170d67",
        "publisherName": "SQLPlayer",
        "displayName": "AzurePlayer",
        "flags": 2,
        "domain": "https://sqlplayer.net",
        "isDomainVerified": true
    },
    "extensionId": "d729bc25-03da-47fb-8b04-7cdc6f15df0e",
    "extensionName": "DataFactoryTools",
    "displayName": "Deploy Azure Data Factory (#adftools)",
    "flags": 260,
    "lastUpdated": "2023-05-16T22:39:13.940Z",
    "publishedDate": "2020-05-11T22:03:16.563Z",
    "releaseDate": "2020-05-27T01:18:46.197Z",
    "shortDescription": "Tools for deploying entire ADF code (JSON files) to ADF instance",
    "versions": [
        {
            "version": "1.29.1369",
            "flags": 1,
            "lastUpdated": "2023-05-16T22:39:13.940Z",
            "files": [

                ...

                {
                    "assetType": "Microsoft.VisualStudio.Services.VSIXPackage",
                    "source": "https://sqlplayer.gallerycdn.vsassets.io/extensions/sqlplayer/datafactorytools/1.29.1369/1684276472780/Microsoft.VisualStudio.Services.VSIXPackage"
                }
            ]
        }
...
Run Code Online (Sandbox Code Playgroud)

或者尝试查看 Azure Pipelines Agent 的_tasks文件夹,如果它仍然缓存了旧版本:

在此输入图像描述