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

huangapple go评论81阅读模式
英文:

Get concrete task version in Azure DevOps pipeline

问题

这是我的任务代码:

- task: PublishADFTask@1
  displayName: '发布数据工厂'
  inputs:
       // 输入部分

但在最新的1.*版本中存在一个错误。

在Azure DevOps YAML管道中是否有一种方式可以使用以前任务的版本?

我尝试了:

- task: PublishADFTask@1.27.1315
  displayName: '发布数据工厂'
  inputs:
       // 输入部分

但它不起作用。

英文:

This is my task code:

- task: PublishADFTask@1
  displayName: 'Publish Datafactory'
  inputs:
       // inputs there

But there is a bug in latest 1.* version.

Is it a way to use previous task's version in azure devops yaml pipelines?

i tried:

- task: PublishADFTask@1.27.1315
  displayName: 'Publish Datafactory'
  inputs:
       // inputs there

But it doesnt work

答案1

得分: 5

以下是翻译好的内容:

只要组织中安装了旧版本,这应该可以正常工作。如果需要,您可以使用 tfx build tasks upload 或 PowerShell 脚本来强制上传旧版本到组织中。如果有人卸载并重新安装扩展程序以尝试解决问题,旧版本可能已经丢失。

要上传任务的旧版本,请首先确保您有一个已知为良好版本的任务版本的 zip 文件或任务可用的文件夹,然后运行以下命令:

# 使用 Node 16 或更高版本
npm install -g tfx-cli

# 对于已提取的任务文件夹
tfx build tasks upload --task-path ..27.1315

# 对于已压缩的任务
tfx build tasks upload --task-zip-path .\mytask.zip

或者使用此 PowerShell 片段:

如果需要,可以直接从 Azure DevOps Marketplace 下载任务的旧版本。以下命令应该将所有可用版本输出到输出中。找到您想要的版本,并查找类型为 Microsoft.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"
                }
            ]
        }
    ...

或者尝试查看 Azure Pipelines 代理的 _tasks 文件夹,看看它是否仍然具有旧版本的缓存:

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

英文:

That should work as long as the old version was installed in the organisation. If needed you can force-upload the older version into the org using tfx build tasks upload or a powershell script. The old version may have gone missing if someone has uninstalled and reinstalled the extension in an attempt to fix the problem.

To upload the older version of the task, first make sure you have a zipfile of the task version you know is good or a folder in which the task is available, then run:

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

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

# for a zipped up task
tfx build tasks upload --task-zip-path .\mytask.zip

Or use this PowerShell snippet:

"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)"
}

I have the whole process laid out in a blog post.

If needed, download the older version of the task straight from the Azure DevOps Marketplace. The following command should dump all the available versions to the output. FInd the version you want and look for the asset of type Microsoft.VisualStudio.Services.VSIXPackage to get the download url of an older version of the extension:

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"
                }
            ]
        }
...

Or try looking on the Azure Pipelines Agent's _tasks folder if it still has the older version cached:

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

huangapple
  • 本文由 发表于 2023年5月17日 20:13:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/76271988.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定