VSTS-从发布视图取消升级软件包版本 [英] VSTS - unpromote a package version from release view

查看:94
本文介绍了VSTS-从发布视图取消升级软件包版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的项目当前正在使用VSTS(Visual Studio Team Services)软件包在项目之间共享软件包。我们要采用





并使用PowerShell来实现示例,脚本可以是:

  $ releaseViewURL = https://marinaliu.pkgs.visualstudio.com/DefaultCollection/_apis/packaging/feeds/new/nuget/packages/ConsoleApp1/versions/1.5.0-alpha?api-version=5.0-preview.1 


$ json ='
{
views:
{ op: add,
path: / views /-,
value: pre}
}
'
$ bodyJson = $ json | ConvertFrom-Json

$ user = name
$ token = p1tjzehdq6tilwfjdbgbkymo3f3ojszmrlfgzh302fww6kgwnavq
$ base64AuthInfo = [Convert] :: ToBase64String([Text.Encoding] :: ASCII。 GetBytes(( {0}:{1} -f $ user,$ token)))

$ response = Invoke-RestMethod -Uri $ releaseViewURL -Headers @ {Authorization =( 0} -f $ base64AuthInfo)} -ContentType application / json-方法补丁-Body $ bodyJson


Our projects is currently using VSTS (Visual Studio Team Services) packages for sharing packages between projects. We want to adopt the Release Views feature to pick up packages at different stages of maturity for automated releases to different environments.

While it is pretty easy to promote a package to a specific view, I have not found a way to unpromote the package from that view. This could be needed for a couple of reasons:

  1. Package was promoted by mistake.
  2. Package needs to be unpromoted because of some issues found and thus needing to demote it to a lower maturity level.

I did not find a direct way of doing it via the VSTS user interface. I did find some articles of doing it via REST APIs, but looks like the current APIs under the Feeds don't support this any more.

Does anyone know how to achieve this?

解决方案

For now, there is no way to unpromoted packages in VSTS package management.

And I posted an user voice Enable to unpromote package in VSTS package management and update REST API document, which suggests to add the feature to unpromote packages and update the REST API document. You can vote and follow up.

And the REST API to promote a NuGet package as below:

PATCH https://{account}.pkgs.visualstudio.com/DefaultCollection/_apis/packaging/feeds/{feedId}/nuget/packages/{packageId}/versions/{packageVersion}?api-version=5.0-preview.1

application/json:

{
 "views": 
   { "op":"add", 
     "path":"/views/-", 
     "value":"release view" }
 }

Note:

  • For feedId and packageId in request URL, you can use feed name and package name instead.
  • For REST API versions, you can also use the older version like 3.0-preview.1.

As below example to promote nuget package ConsoleApp1 with version 1.5.0-alpha in new feed for pre view, the REST API is (response with 202 Accepted state if success):

And use the PowerShell to achieve the example, and script can be:

$releaseViewURL = "https://marinaliu.pkgs.visualstudio.com/DefaultCollection/_apis/packaging/feeds/new/nuget/packages/ConsoleApp1/versions/1.5.0-alpha?api-version=5.0-preview.1"


$json = '
 {
 "views": 
 { "op":"add", 
 "path":"/views/-", 
 "value":"pre" }
 }
'
$bodyJson=$json | ConvertFrom-Json

$user="name"
$token="p1tjzehdq6tilwfjdbgbkymo3f3ojszmrlfgzh302fww6kgwnavq"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))

$response = Invoke-RestMethod -Uri $releaseViewURL -Headers  @{Authorization=("Basic {0}" -f $base64AuthInfo)} -ContentType "application/json" -Method Patch -Body $bodyJson

这篇关于VSTS-从发布视图取消升级软件包版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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