renevanosnabrugge / vsts-promotepackage-task

Promote a package in VSTS to a Release View
MIT License
21 stars 25 forks source link

VSTS Package Server URLs are out of date #6

Closed chambomusic closed 5 years ago

chambomusic commented 6 years ago

When attempting to use this extension to push packages to a VSTS Package view I receive the following error in the VSTS log: ##[error]The remote server returned an error: (400) Bad Request.

It appears VSTS has changed the package server URLs.

Currently my package is hosted at: https://{account}.visualstudio.com/{team}/_packaging?feed={packageFeed}&_a=feed

This is different from what appears in the powershell script:
$basepackageurl = ("https://{0}.pkgs.visualstudio.com/DefaultCollection/_apis/packaging/feeds" -f $account) $basefeedsurl = ("https://{0}.feeds.visualstudio.com/DefaultCollection/_apis/packaging/feeds" -f $account) $packageURL = "$basefeedsurl/$feedName/packages/$packageId/?api-version=2.0-preview"

Attempting to navigate directly to the URL in the powershell script formatted with my account/feed/etc results in a 404 error.

DavidJFowler commented 6 years ago

HI,

I'm also experiencing this problem. Is there a workaround?

chambomusic commented 6 years ago

@DavidJFowler - I've not yet found one. Keep me posted if you come up with anything. Currently I'm using a send email task to notify the release requester to push the packages manually. Certainly not ideal and definitely not automatic or foolproof.

Based on reading through some MS VSTS issue threads it sounds like we may be getting some package management improvements soon. Hopefully the MS improvements will remove the need for this extension.

renevanosnabrugge commented 6 years ago

Hi,

Sorry for the delayed response. I've been quite busy. I have tested on my own VSTS (multiple) and it all works. In the documentation https://www.visualstudio.com/en-us/docs/integrate/api/packaging/nuget#release-package there is also the url that is used..

Have you tried postman (or something) to run this patch?

try to run this powershell in ISE or powershell and see if it works..

$accountname = "vsts account name "
$pat = "pat"
$basepackageurl = ("https://$accountname.pkgs.visualstudio.com/DefaultCollection/_apis/packaging/feeds" -f $account)
$releaseView = "namereleaseview"
$feedname = "feedname"
$packageName = "packagename"
$packageVersion = "1.3.0"

$userpass = ":$($pat)"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($userpass))
$token = "Basic $encodedCreds"

     $releaseViewURL = "$basepackageurl/$feedName/nuget/packages/$packageName/versions/$($packageVersion)?api-version=3.0-preview.1"

     $json = @{
        views = @{
            op = "add"
            path = "/views/-"
            value = "$releaseView"
        }
    }
    $response = Invoke-RestMethod -Uri $releaseViewURL -Headers @{Authorization = $token} -ContentType "application/json" -Method Patch -Body (ConvertTo-Json $json)
    return $response
DavidJFowler commented 6 years ago

The powershell works but the VSTS build step is still failing with "The remote server returned an error: (400) Bad Request."

renevanosnabrugge commented 6 years ago

can you send me the logfile (system.debug set to true in the build/release) and a screendump of the filled in parameters? You can send it to me in an email rvanosnabrugge AT Live DOT com

DavidJFowler commented 6 years ago

If you select the package using the drop down on the task definition it works. if you type a name in, or use a variable you get the bad request error.

chambomusic commented 6 years ago

I can confirm what @DavidJFowler says - you must select the package from the drop down for the task to work properly. @renevanosnabrugge can this be improved to allow the use of variable names in the parameter input fields?

dhuesmann89 commented 5 years ago

I can confirm what @DavidJFowler says - you must select the package from the drop down for the task to work properly. @renevanosnabrugge can this be improved to allow the use of variable names in the parameter input fields?

This should now be working with #14

renevanosnabrugge commented 5 years ago

Fixed in 1.2.10