我们的人工制品是一个章鱼nuget包。当构建发布时,它会进入QA阶段,在那里通过八达通部署工件。这只章鱼直接从Azure工件nuget饲料中消耗它。
如果部署和随后的测试是成功的,我们希望将工件提升到Azure工件nuget提要的发布视图,因为我们认为它提供了一个不同的nuget URL,可以由另一个为下一阶段服务的章鱼使用(出于历史原因,我们每个阶段都有专门的Octopus --致力于改变这一点,但这需要时间)。
我们可以手动提升,但我们想要自动进行。这是如何做到的呢?
我们正在现场TFS 2019 RC2上进行测试.
编辑1
建议的插件似乎没有安装在现场TFS 2019 RC2上:
发布于 2020-05-26 22:02:52
用PowerShell..。
$organisationName = '' # Name of organisation
$projectName = '' # Name of project
$feedName = '' # Name of Azure Artifacts feed
$viewName = 'Release' # I believe this can also be Prerelease, but I've not tried it
# List of names of packages within Azure Artifacts feed to be promoted
$packagesToPromote = @('')
# Need a personal access token for this script to work
# PAT token should be assigned to Packaging (Read, Write and Manage) scopes
$azureArtifactsPAT = ''
$AzureArtifactsPAT_Base64 = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$($azureArtifactsPAT)"))
$restAPICallHeader = @{ Authorization = "Basic $AzureArtifactsPAT_Base64" }
$feedBaseURL = "https://feeds.dev.azure.com/$organisationName/$projectName/_apis/packaging/feeds"
$packageBaseURL = "https://pkgs.dev.azure.com/$organisationName/$projectName/_apis/packaging/feeds"
$feedIdURL = "$feedBaseURL/$feedName/?api-version=5.1-preview.1"
$feedIdResponse = (Invoke-RestMethod -Method Get -Uri $feedIdUrl -Headers $restAPICallHeader -ContentType 'application/json')
$feedId = $feedIdResponse.id
$viewIdURL = "$feedBaseURL/$feedId/views/$viewName/?api-version=5.1-preview.1"
$viewIdResponse = (Invoke-RestMethod -Method Get -Uri $viewIdUrl -Headers $restAPICallHeader -ContentType 'application/json')
$viewId = $viewIdResponse.id
$restAPICallBodyJson = @{
views = @{
op = 'add'
path = '/views/-'
value = "$viewId"
}
}
$restAPICallBody = (ConvertTo-Json $restAPICallBodyJson)
foreach ($packageName in $packagesToPromote) {
$packageQueryUrl = "$feedBaseURL/$feedId/packages?api-version=5.1-preview.1&packageNameQuery=$packageName"
$packagesResponse = (Invoke-RestMethod -Method Get -Uri $packageQueryUrl -Headers $restAPICallHeader -ContentType 'application/json')
$latestPackageVersion = ($packagesResponse.value.versions | ? { $_.isLatest -eq $True } | Select -ExpandProperty version)
$encodedPackageVersion = [System.Web.HttpUtility]::UrlEncode($latestPackageVersion)
Write-Host "Package Name: $packageName"
Write-Host "Package Version: $latestPackageVersion"
$releaseViewURL = $packageBaseURL `
+ "/$($feedId)" `
+ "/nuget/packages/$packageName" `
+ "/versions/$encodedPackageVersion" `
+ "?api-version=5.1-preview.1"
$response = Invoke-RestMethod -Method Patch -Uri $releaseViewURL -Headers $restAPICallHeader -ContentType 'application/json' -Body $restAPICallBody
Write-Host $response
}
作为参考,上面的脚本使用以下API调用:
饲料管理-获取饲料
源管理-获取源视图
伪影详细信息-获取包
NuGet -更新包版本
发布于 2019-02-04 22:14:43
根据Azure DevOps文档,市场任务将包推广到发布视图是通过CI/CD管道实现这一目标的推荐方法。
存储库可以在Github上找到。
编辑:
因为您是在prem上使用此任务不支持的版本。我想说的是,关于使用REST的评论将是在类似powershell脚本的情况下使用的路线。
由于从未在此任务中使用REST Api,我不太确定身体应该如何查找请求。然而,它似乎是文档化的这里。
我对JSON修补对象的理解是有限的,但我认为您可以使用replace
操作。
{ "op": "replace", "path": "/view", "value": "@Release" }
这篇文章也可能有帮助,但我仍然没有看到任何与from
定义上的JsonPatchObject
标识符相关的东西。
发布于 2019-02-05 14:09:22
最近,我还在尝试使用TFS实现版本时遇到了困难。我已经制作了一些PowerShell脚本(在web上修改其他脚本)来进行包版本控制。
https://gist.github.com/oceanexplorer/6a91930419b35c1923974af265777a5f
https://gist.github.com/oceanexplorer/35e0f26962018dc8578c745060365c15
第一步是我的构建管道,我使用“更新AssemblyInfo”任务来设置构建版本,然后将其嵌入到DLL中。
https://marketplace.visualstudio.com/items?itemName=sebastianlux.UpdateAssemblyInfo
最初,我将上面的脚本嵌入到我的项目中以启动工作,但最终在我的发布管道中,我有一个任务,通过一个"NuGet安装“任务部署这些构建脚本,该任务有效地将它们从提要中拉出并解压缩。
在发布管道中,我有一个任务"Version Package“,它是一个自定义的PowerShell脚本,它调用上述两个要点中定义的函数,它们所做的是解压缩从构建管道创建并放置在工件目录中的NuGet包,将正确的版本控制应用于包并将其压缩回原来的位置。我在构建管道中使用了以下版本号格式:
$(version.major).$(version.minor).$(version.patch).$(Date:yyyyMMdd)$(Rev:r)-CI
1.0.0.201902051-CI
This will produce a semantic build number format of:
1.0.0-alpha.201902051
我使用内联PowerShell任务调用脚本
##-------------------------------------------
## Import Build Scripts
##-------------------------------------------
gci -Recurse "$(System.DefaultWorkingDirectory)\scripts\*.psm1" | ForEach-Object { Import-Module $_.FullName }
##-------------------------------------------
## Version Files
##-------------------------------------------
Expand-NugetPackages -packagesDirectory "$(artifact.directory)" -Verbose
Add-VersionToAssemblies -suffix "$(Release.EnvironmentName)" -semVer "2.0" -artifactsToApplyTo "nuspec" -isRelease $(isRelease) -Verbose
Compress-NugetPackages -packagesDirectory "$(artifact.directory)" -Verbose
然后执行一个NuGet推送任务来推送包
它们是另一个内联PowerShell脚本,它设置包提要的发布视图:
##-------------------------------------------
## Import Build Scripts
##-------------------------------------------
gci -Recurse "$(System.DefaultWorkingDirectory)\scripts\*.psm1" | ForEach-Object { Import-Module $_.FullName }
##-------------------------------------------
## Set Package Quality
##-------------------------------------------
Set-PackageQuality -feedName "Libraries" -packageId $(nuget.packageId) -packageVersion $env:semanticVersion -packageQuality $(Release.EnvironmentName)
https://stackoverflow.com/questions/54523682
复制相似问题