renevanosnabrugge / vsts-promotepackage-task

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

Feature: Multiple Packages #25

Closed NightOwl888 closed 5 years ago

NightOwl888 commented 5 years ago

This PR includes 2 new features:

18 - Promotion of multiple packages in one go (by specifying the package ids separated by semicolons)

Makes it possible to use a Powershell task to get package ids from whatever format they may be in to a simple list like PackageA;PackageB;PackageC. This seems like a better option than hard wiring some wildcard logic into this task and opens up a range of use cases that go beyond the scope of #18.

Promotion of multiple packages and versions by specifying package file paths (and/or glob patterns)

This feature is one that I will personally use - to re-use the same blobs I just used to push the packages to the feed in order to promote those same packages to a new view.

**/*.nupkg
!**/*.symbols.nupkg

There will be an option button on the UI which will make the current Package and Package version fields invisible, while making the Packages source folder and Package contents fields visible.

NOTE: The screenshot in the documentation will need to be updated.

Reasoning for this Feature:

This task is almost always going to follow a task that pushes packages to a package feed. The file names (or globs) of those packages will likely already be in the context of the pipeline. The file naming conventions of packages for both NPM and NuGet always follow known conventions, and contain exactly the information that is needed (package id and version) that can be used for promotion. It seems like an extra unnecessary step to specify the package id - when using globs in the build/release pipeline, the package ids won't exist anywhere in the pipeline except on the file names of the actual packages.

This feature also enables a use case where the packages being promoted don't all have the same version number.

Testing

I had a bit of trouble trying to work out how testing is supposed to be done here, but since I didn't change anything after the Run method, I was able to test the logic that was added by commenting everything except for Write-Host in the Set-PackageQuality function and also commenting the call to Initialize-Request (which contains all but the last line of the former Run method).

In a nutshell, the only real change to the former logic was to separate Initialize-Request from Set-PackageQuality so the initalization could be run only once, while calling Set-PackageQuality multiple times. You had these pretty well separated already, so this was just moving one function call. Although I wasn't able to run all of the code, I am pretty sure the code will function as is.

Here is the script I used to debug:

# Must run from within the vsts-promotepackage-task folder
Import-Module .\ps_modules\VsTsTaskSdk

$env:SYSTEM_TEAMFOUNDATIONSERVERURI = "https://dev.azure.com/myorg"

$env:INPUT_FEED = "myfeed"
$env:INPUT_INPUTTYPE = "packageFiles" #"nameVersion"
$env:INPUT_RELEASEVIEW = "CI"
$env:INPUT_PACKAGEIDS = "TestLibrary;FooLibrary" #"TestLibrary"
$env:INPUT_VERSION = "1.2.90"

$env:INPUT_PACKAGESDIRECTORY = 'F:/Temp/TestArtifacts'
$env:INPUT_PACKAGESPATTERNPARSE = "**\*.nupkg`n!**\*.symbols.nupkg`n**\*.tgz"

Invoke-VsTsTaskScript -ScriptBlock { . .\vsts-promotepackage-task.ps1 } -Verbose

If you don't have time to test this yourself, I could do it if you could provide some guidance on how you are testing this task.

It might be helpful if you create a quick wiki page explaining what testing input values are required and some possible dummy values if a real value isn't necessarily needed. The @runlocal argument is a bit confusing, since it effectively runs nothing when set to $true, but without this set a PAT cannot be overridden using an environment variable.

Dependencies

Do note that the biggest change here was upgrading the VstsTaskSdk to the latest version. The upgrade was not necessarily needed, but the former pull of the SDK didn't have the binary .dll files, and without them the blob functionality doesn't work. I didn't test these changes with the former SDK version, but I know for sure that Minimatch.dll is required. If you want to revert/exclude the SDK commit, it probably won't be a problem as long as you grab that .dll and check carefully for other missing dependencies.

Backward Compatibility

These features should be backward compatible (untested), but since this is more than a patch I would still recommend bumping the version to 2.x to prevent breaking anyone's builds.

Feed Support

Since you have already stated that only NPM and NuGet feeds are supported, those are the only package types the Get-PackageNameAndVersion function supports. However, for maintainability separate regexes were used for each package type, so support for other package types can be added simply by adding the new regex to a new variable and changing this line to add the new variable to the array. The only condition is that named capturing groups name and version must be included in the regex.

Maybe in some future version the regex could be specified as a parameter, but since the conventions that the packaging tools use are standardized, this should not really be necessary.

renevanosnabrugge commented 5 years ago

Hi,

Thanks for you really extensive pull request. I am happy to accept. In terms of testing. I have a poor man solution. I added the task to the pipeline and have some packages that I try to push.

That is what I will do, when I accept, but I am short on time. If you tested it, and say it’s fine, I can run a quick test an dpublish. I will make this a new Major version, because a lot of things have changed. People can revert to a previous version then as well.

I can also push it and publish a private version to you only. Please send me your Azure DevOps Account name, and I can do that. Then you can use that task in your pipeline to test.

Many thanks! Rene

From: Shad Storhaug notifications@github.com Sent: Wednesday, June 26, 2019 12:58 PM To: renevanosnabrugge/vsts-promotepackage-task vsts-promotepackage-task@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [renevanosnabrugge/vsts-promotepackage-task] Feature: Multiple Packages (#25)

This PR includes 2 new features:

18https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frenevanosnabrugge%2Fvsts-promotepackage-task%2Fissues%2F18&data=02%7C01%7C%7C6a30e5d622be4ad38b1c08d6fa251a7d%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636971434595346431&sdata=IbtyIj3xqUd0k64U8WQ4K9betB6ntDYk%2Bqg4%2F44zOJ8%3D&reserved=0 - Promotion of multiple packages in one go (by specifying the package ids separated by semicolons)

Makes it possible to use a Powershell task to get package ids from whatever format they may be in to a simple list like PackageA;PackageB;PackageC. This seems like a better option than hard wiring some wildcard logic into this task and opens up a range of use cases that go beyond the scope of #18https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frenevanosnabrugge%2Fvsts-promotepackage-task%2Fissues%2F18&data=02%7C01%7C%7C6a30e5d622be4ad38b1c08d6fa251a7d%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636971434595366441&sdata=qZV%2B6jGBv7GdffE4ygjnkRiD7%2Fd7DwmUB2cK2Dazms4%3D&reserved=0.

Promotion of multiple packages and versions by specifying package file paths (and/or glob patterns)

This feature is one that I will personally use - to re-use the same blobs I just used to push the packages to the feed in order to promote those same packages to a new view.

*/.nupkg

!*/.symbols.nupkg

There will be an option button on the UI which will make the current Package and Package version fields invisible, while making the Packages source folder and Package contents fields visible.

NOTE: The screenshot in the documentation will need to be updated.

Reasoning for this Feature:

This task is almost always going to follow a task that pushes packages to a package feed. The file names (or globs) of those packages will likely already be in the context of the pipeline. The file naming conventions of packages for both NPM and NuGet always follow known conventions, and contain exactly the information that is needed (package id and version) that can be used for promotion. It seems like an extra unnecessary step to specify the package id - when using globs in the build/release pipeline, the package ids won't exist anywhere in the pipeline except on the file names of the actual packages.

This feature also enables a use case where the packages being promoted don't all have the same version number.

Testing

I had a bit of trouble trying to work out how testing is supposed to be done here, but since I didn't change anything after the Run method, I was able to test the logic that was added by commenting everything except for Write-Host in the Set-PackageQuality functionhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FNightOwl888%2Fvsts-promotepackage-task%2Fblob%2F7d579b97fb01cfe9f2159bb43d3c04b6926f8e0c%2Fvsts-promotepackage-task%2Fvsts-promotepackage-task.ps1%23L178-L204&data=02%7C01%7C%7C6a30e5d622be4ad38b1c08d6fa251a7d%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636971434595376446&sdata=R7CQ09xDLaZQeL5SuAQj76ZwrN4SVndXd9U%2B3RCyUvg%3D&reserved=0 and also commenting the call to Initialize-Requesthttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FNightOwl888%2Fvsts-promotepackage-task%2Fblob%2F7d579b97fb01cfe9f2159bb43d3c04b6926f8e0c%2Fvsts-promotepackage-task%2Fvsts-promotepackage-task.ps1%23L241&data=02%7C01%7C%7C6a30e5d622be4ad38b1c08d6fa251a7d%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636971434595386457&sdata=9X78QEnY9NH1rMsbOvKvaposVg82Qs4khWQO8bpSznQ%3D&reserved=0 (which contains all but the last line of the former Run method).

In a nutshell, the only real change to the former logic was to separate Initialize-Request from Set-PackageQuality so the initalization could be run only once, while calling Set-PackageQuality multiple times. You had these pretty well separated already, so this was just moving one function call. Although I wasn't able to run all of the code, I am pretty sure the code will function as is.

Here is the script I used to debug:

Must run from within the vsts-promotepackage-task folder

Import-Module .\ps_modules\VsTsTaskSdk

$env:SYSTEM_TEAMFOUNDATIONSERVERURI = "https://dev.azure.com/myorg"

$env:INPUT_FEED = "myfeed"

$env:INPUT_INPUTTYPE = "packageFiles" #"nameVersion"

$env:INPUT_RELEASEVIEW = "CI"

$env:INPUT_PACKAGEIDS = "TestLibrary;FooLibrary" #"TestLibrary"

$env:INPUT_VERSION = "1.2.90"

$env:INPUT_PACKAGESDIRECTORY = 'F:/Temp/TestArtifacts'

$env:INPUT_PACKAGESPATTERNPARSE = "*.nupkg`n!*.symbols.nupkg`n*\.tgz"

Invoke-VsTsTaskScript -ScriptBlock { . .\vsts-promotepackage-task.ps1 } -Verbose

If you don't have time to test this yourself, I could do it if you could provide some guidance on how you are testing this task.

It might be helpful if you create a quick wiki page explaining what testing input valueshttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fazure-pipelines-task-lib%2Fblob%2Fmaster%2Fpowershell%2FDocs%2FTestingAndDebugging.md&data=02%7C01%7C%7C6a30e5d622be4ad38b1c08d6fa251a7d%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636971434595396455&sdata=5hJVkiqj0BXFgnqI3abK7O2wMFDDWP6ZIwoHXJDm0XQ%3D&reserved=0 are required and some possible dummy values if a real value isn't necessarily needed. The @runlocal argument is a bit confusing, since it effectively runs nothing when set to $true, but without this set a PAT cannot be overridden using an environment variable.

Dependencies

Do note that the biggest change here was upgrading the VstsTaskSdk to the latest version. The upgrade was not necessarily needed, but the former pull of the SDK didn't have the binary .dll files, and without them the blob functionality doesn't work. I didn't test these changes with the former SDK version, but I know for sure that Minimatch.dll is required. If you want to revert/exclude the SDK commit, it probably won't be a problem as long as you grab that .dll and check carefully for other missing dependencies.

Backward Compatibility

These features should be backward compatible (untested), but since this is more than a patch I would still recommend bumping the version to 2.x to prevent breaking anyone's builds.

Feed Support

Since you have already stated that only NPM and NuGet feeds are supported, those are the only package types the Get-PackageNameAndVersion function supports. However, for maintainability separate regexes were used for each package type, so support for other package types can be added simply by adding the new regex to a new variable and changing this linehttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FNightOwl888%2Fvsts-promotepackage-task%2Fblob%2F7d579b97fb01cfe9f2159bb43d3c04b6926f8e0c%2Fvsts-promotepackage-task%2Fvsts-promotepackage-task.ps1%23L159&data=02%7C01%7C%7C6a30e5d622be4ad38b1c08d6fa251a7d%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636971434595406473&sdata=A62UJVUeWggfSXFx%2BYmroI8ZFi3jEBZjZ5mzm%2B3aecA%3D&reserved=0 to add the new variable to the array. The only condition is that named capturing groups name and version must be included in the regex.

Maybe in some future version the regex could be specified as a parameter, but since the conventions that the packaging tools use are standardized, this should not really be necessary.


You can view, comment on, or merge this pull request online at:

https://github.com/renevanosnabrugge/vsts-promotepackage-task/pull/25https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frenevanosnabrugge%2Fvsts-promotepackage-task%2Fpull%2F25&data=02%7C01%7C%7C6a30e5d622be4ad38b1c08d6fa251a7d%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636971434595416477&sdata=9xpVksmaWNISZYMLMaDpfyxTLUdHCczf4c%2BEkELBwmk%3D&reserved=0

Commit Summary

File Changes

Patch Links:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frenevanosnabrugge%2Fvsts-promotepackage-task%2Fpull%2F25%3Femail_source%3Dnotifications%26email_token%3DABOH2WTKCO7UKEQEV7GZVOTP4NDSDA5CNFSM4H3RAC3KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G3YZ3HQ&data=02%7C01%7C%7C6a30e5d622be4ad38b1c08d6fa251a7d%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636971434595676691&sdata=CLMTTfIavXVy2a95%2B14rNxEHwRPoHijoq4Bw8PRteH8%3D&reserved=0, or mute the threadhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABOH2WQ352DQXPXBL3UNYITP4NDSDANCNFSM4H3RAC3A&data=02%7C01%7C%7C6a30e5d622be4ad38b1c08d6fa251a7d%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636971434595686690&sdata=nvxDlE7GOzJdyrfe1wXNYB1a2WtTq7a2k6qxJN0FiYI%3D&reserved=0.

NightOwl888 commented 5 years ago

Thanks for the prompt reply.

I can also push it and publish a private version to you only. Please send me your Azure DevOps Account name, and I can do that. Then you can use that task in your pipeline to test.

If you are referring to organization name, it is essco-stores. I don't currently have any live pipelines using this task, so pushing a new version should be okay.

If you are referring to the account I log into Azure DevOps with, it is the same email address as in my git commit history.

It will be great to be able to try it out installed so I can confirm backward compatibility and make any tweaks to the visual experience.

renevanosnabrugge commented 5 years ago

I’l try to do iT asap

Verstuurd vanaf mijn iPhone

Op 26 jun. 2019 om 14:35 heeft Shad Storhaug notifications@github.com<mailto:notifications@github.com> het volgende geschreven:

Thanks for the prompt reply.

I can also push it and publish a private version to you only. Please send me your Azure DevOps Account name, and I can do that. Then you can use that task in your pipeline to test.

If you are referring to organization name, it is essco-stores. I don't currently have any live pipelines using this task, so pushing a new version should be okay.

If you are referring to the account I log into Azure DevOps with, it is the same email address as in my git commit history.

It will be great to be able to try it out installed so I can confirm backward compatibility and make any tweaks to the visual experience.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frenevanosnabrugge%2Fvsts-promotepackage-task%2Fpull%2F25%3Femail_source%3Dnotifications%26email_token%3DABOH2WVRMNKS3OADVDDSWP3P4NPAJA5CNFSM4H3RAC3KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYTL45Y%23issuecomment-505855607&data=02%7C01%7C%7C080545a59a964fe7fdf508d6fa32bf6f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636971493199507517&sdata=vXjskC1HC6O0SeLzCnwrXw9XybMOYY1isj5UniU3hos%3D&reserved=0, or mute the threadhttps://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABOH2WT6RAH66ZPBDTVFMC3P4NPAJANCNFSM4H3RAC3A&data=02%7C01%7C%7C080545a59a964fe7fdf508d6fa32bf6f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636971493199517534&sdata=5Q1YjNy64tJdOZfFl5Vs%2B%2Bzjqz34iTWNOYoA7U4bQ%2BE%3D&reserved=0.

renevanosnabrugge commented 5 years ago

I built and shared the new version with you. Let me know if it works!

NightOwl888 commented 5 years ago

Thanks. I am still trying out the task, but there is a bit of a snag with the visual experience for the version pick list.

I haven't pushed the commit to GitHub yet, but I have changed the pick list for Package to MultiSelectFlatList. This means that the packageIds field (formerly named definition) will be a comma-delimited list of package names or IDs. I had previously changed it to a semicolon-delimited list.

Either way, this poses a slight problem for the databinding for the version field, since it can only work for a single package id.

"endpointUrl": "{{endpoint.url}}/_apis/Packaging/Feeds/{{{feed}}}/Packages/{{{packageIds}}}/Versions?includeUrls=false"

I can think of 4 different options for handling this:

  1. Assuming that the multiple package IDs case fails silently, we could leave it as is. The version list will simply be blank in the case there are multiple packages specified.
  2. Remove the databinding pick list from the version field. This cleans up the visual experience. Frankly, pinning the task to a specific version doesn't seem very practical anyway. This will almost always be a variable.
  3. Add another option button Use latest version/Specify explicit version. Make the default Use latest version (thus breaking backward compatibility), and change the API logic to get the latest version from the feed. Remove the version databindings from Specify explicit version.
  4. Change the Package input type option button to have the options Specify single package and version (default with all v1 inputs), Specify multiple packages (and implement the above logic here), `Parse name(s) and version(s) from package files.

If you know of any way to pull the first packageId out of the the packageIds comma-delimited list, the dropdown could be made to work on the first item without a failure. But that feels a bit broken.

Let me know which option seems most natural to you. Personally, I am leaning toward option 2.

NightOwl888 commented 5 years ago

Unfortunately, it isn't working on the Azure DevOps server. It is failing on the first REST call, Get-FeedId. I am not sure what the issue is because the original error message is not coming through the try/catch block. The error isn't happening when I run it locally using the $env:PAT variable - locally, it runs all the way through to the end.

I have added the original error messages and stack trace to the error that is being re-thrown in order to try to get more info about the nature of the error.

For the time being, I have also removed the pick list from the version field (option 2). This commit can be reverted if you decide otherwise.

Could you please package up a new DEV version and push it to me? Also, if you have time to look into this error, maybe you have more of a clue why it is happening than I.

renevanosnabrugge commented 5 years ago

I do not support the server currently. So that is no problem. Will try to push a new dev version this weekend

Thanks

Verstuurd vanaf mijn iPhone

Op 28 jun. 2019 om 19:59 heeft Shad Storhaug notifications@github.com<mailto:notifications@github.com> het volgende geschreven:

Unfortunately, it isn't working on the Azure DevOps server. It is failing on the first REST call, Get-FeedId. I am not sure what the issue is because the original error message is not coming through the try/catch block. The error isn't happening when I run it locally using the $env:PAT variable - locally, it runs all the way through to the end.

I have added the original error messages and stack trace to the error that is being re-thrown in order to try to get more info about the nature of the error.

For the time being, I have also removed the pick list from the version field (option 2). This commit can be reverted if you decide otherwise.

Could you please package up a new DEV version and push it to me? Also, if you have time to look into this error, maybe you have more of a clue why it is happening than I.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frenevanosnabrugge%2Fvsts-promotepackage-task%2Fpull%2F25%3Femail_source%3Dnotifications%26email_token%3DABOH2WXY52YTCA4XKAIZBOTP4ZGONA5CNFSM4H3RAC3KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY2YSGI%23issuecomment-506824985&data=02%7C01%7C%7Cabd3291909f44244dd5508d6fbf24e07%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636973415434251470&sdata=%2BP96MCm0p%2BuGqK4JKyBlRqlVsct7SzUwi4Xyop%2F%2Fxew%3D&reserved=0, or mute the threadhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABOH2WSGRYCOW7ERYN3I4ETP4ZGONANCNFSM4H3RAC3A&data=02%7C01%7C%7Cabd3291909f44244dd5508d6fbf24e07%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636973415434261475&sdata=fS40IHAr%2F9YeDOACu4GjsAwMwIyjLR0vwd6keke5B3A%3D&reserved=0.

NightOwl888 commented 5 years ago

Oops, I guess that was confusing. I meant it isn't working on the Azure DevOps account you sent it to (the cloud service, not a standalone server).

renevanosnabrugge commented 5 years ago

Ok. Ill try and build the task this weekend

Verstuurd vanaf mijn iPhone

Op 28 jun. 2019 om 20:59 heeft Shad Storhaug notifications@github.com<mailto:notifications@github.com> het volgende geschreven:

Oops, I guess that was confusing. I meant it isn't working on the Azure DevOps account you sent it to (the cloud service, not a standalone server).

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frenevanosnabrugge%2Fvsts-promotepackage-task%2Fpull%2F25%3Femail_source%3Dnotifications%26email_token%3DABOH2WRIJT434ZOGDESIO5TP4ZNS3A5CNFSM4H3RAC3KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODY25D5Y%23issuecomment-506843639&data=02%7C01%7C%7C18a5376d563b472ca25908d6fbfad118%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636973451992382493&sdata=tTnXndydWZoRJxthF0RwTTolaGUzcr%2F%2FzJkesfOVdR4%3D&reserved=0, or mute the threadhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABOH2WRWIAT6HTUYO2DAIH3P4ZNS3ANCNFSM4H3RAC3A&data=02%7C01%7C%7C18a5376d563b472ca25908d6fbfad118%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636973451992402516&sdata=KE17RwDbhf%2FZJO5wJG%2F6lEMwWuJPQ%2FSsqRPETklbRsg%3D&reserved=0.

NightOwl888 commented 5 years ago

Update

I took it upon myself to make some local builds and debug them to work out what the issue was. It was due to the fact that the flow of the script expected the calls in a specific order in order to maintain the scope of the variables. Moving that one method call broke that order, which was what caused it to fail.

Function Calls

Since that is quite confusing to contributors, I ended up adding function parameters to explicitly define what dependencies are required by each function. I wrapped the base URLs and headers into a custom PS object called $requestContext that is passed to each of the REST API functions.

Testing

Also, since that broke the ability to test, I updated the tests so they use the functionality built into the VstsTaskSdk to pass in values.

Package "Parsing"

I discovered that the package names don't always reflect the true version of the package. SemVer 2 allows passing metadata, which is recorded in the metadata, but not reflected on the name of the file. So, I changed the approach to extract the metadata from the packages rather than using a regular expression on the file name, which will ensure the name and version always matches what is in the feed.

Backward Compatibility

I have confirmed in one YAML configuration test that passing in the values using the original names still works. So, technically there is no reason to bump the major version, but this is definitely at least a minor version update.

Feed Support

I noticed that what is stated in the main part of the README has some updates in the release notes and made some attempts to add support for more package types using metadata. But, in the end the new functionality still only supports NuGet and NPM.

Universal Packages

Using the portal, there is no way to download these that I could find. Using the command line tools, only the package contents are downloaded. So, it appears the metadata for the packages only exists on the server. There would be no reasonable way to support a metadata approach for these, the original "name and version" way seems to be the only option here.

Conclusion

I have run a few tests using a private copy of this on Azure Pipelines and everything seems to be working well. I know you don't have a lot of time to dedicate to this, so I updated the screenshots so all you really need to do is bump the version, confirm it functions, and release it. Let me know if anything needs to be addressed before releasing it.

renevanosnabrugge commented 5 years ago

I shared a private preview with you again.. Can you test? For me it seems to work

NightOwl888 commented 5 years ago

Confirmed it is working on my end with NuGet glob patterns. Looks good!

renevanosnabrugge commented 5 years ago

Awesome! I Will push a new version today

Verstuurd vanaf mijn iPhone

Op 19 jul. 2019 om 07:55 heeft Shad Storhaug notifications@github.com<mailto:notifications@github.com> het volgende geschreven:

Confirmed it is working on my end with NuGet glob patterns. Looks good!

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frenevanosnabrugge%2Fvsts-promotepackage-task%2Fpull%2F25%3Femail_source%3Dnotifications%26email_token%3DABOH2WRDJPWEYSIPVULCA53QAFJOVA5CNFSM4H3RAC3KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2KU4JA%23issuecomment-513101348&data=02%7C01%7C%7Cad5bb05f54ae4328525908d70c0dc397%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636991125555763319&sdata=uvsQfxGEBRbWgAWwhkk%2FNQ5MN0U0HJXqlwXYvis65xw%3D&reserved=0, or mute the threadhttps://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABOH2WWAJECZD4ZJ654M2KTQAFJOVANCNFSM4H3RAC3A&data=02%7C01%7C%7Cad5bb05f54ae4328525908d70c0dc397%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636991125555773324&sdata=4F1aeON06IAHO%2FLEc2K2RAJvUBWe8HHYhY%2FkYF2UzRs%3D&reserved=0.

renevanosnabrugge commented 5 years ago

Published version 1.4.2 Thanks for all your hard work !

SanderGcNL commented 5 years ago

First of all, thanks for all the hard work!

Looks like we're having some backwards compatibility issues on our end. Our releases using the task fail since this update; with following message: img1

When opening the definition i'm greeted with the following setting needs attention on all stages:

img2

I'm not totally sure what the value of the field marked in red was before the update and i can't recall if we customized it any further, but i think it was a default value based on the name of the selected artifact on the artifact feed.

renevanosnabrugge commented 5 years ago

Can you use the previous version of the task?

Verstuurd vanaf mijn iPhone

Op 19 jul. 2019 om 12:47 heeft SanderGcNL notifications@github.com<mailto:notifications@github.com> het volgende geschreven:

First of all, thanks for all the hard work!

Looks like we're having some backwards compatibility issues on our end. Our releases using the task fail since this update; with following message: [img1]https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F53082496%2F61529711-57ca5a80-aa22-11e9-99b2-0dae87d02860.png&data=02%7C01%7C%7C4538e5ec71b1429bef5008d70c367d52%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636991300481184161&sdata=3eQWCkIi7hQVuQIKVV6atAmaH3vgLgpTY13xNgjdSpQ%3D&reserved=0

When opening the definition i'm greeted with the following setting needs attention on all stages:

[img2]https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F53082496%2F61529833-a841b800-aa22-11e9-8905-5ebbe633d080.png&data=02%7C01%7C%7C4538e5ec71b1429bef5008d70c367d52%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636991300481194172&sdata=axb2l6o9ZdBU8okserXqVFCpIhp3A%2FX%2B5vg7nv8XXg0%3D&reserved=0

I'm not totally sure what the value of the field marked in red was before the update and i can't recall if we customized it any further, but i think it was a default value based on the name of the selected artifact on the artifact feed.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHubhttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frenevanosnabrugge%2Fvsts-promotepackage-task%2Fpull%2F25%3Femail_source%3Dnotifications%26email_token%3DABOH2WX6Y5R6XQAYDRCE3WDQAGLT5A5CNFSM4H3RAC3KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2LJGGQ%23issuecomment-513184538&data=02%7C01%7C%7C4538e5ec71b1429bef5008d70c367d52%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636991300481204189&sdata=j0C%2FS2d%2BWMa4RwbiXtWniyV94Lo4R2WnZ77JTqf065A%3D&reserved=0, or mute the threadhttps://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABOH2WUPPFVR7G376PLQ6KTQAGLT5ANCNFSM4H3RAC3A&data=02%7C01%7C%7C4538e5ec71b1429bef5008d70c367d52%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636991300481214182&sdata=po1Qp%2BA36Cr1ZNB%2B1k3MyLio9Xitkut5Na1TnFHZpBw%3D&reserved=0.

NightOwl888 commented 5 years ago

@SanderGcNL

The "definition" field was renamed to "packageIds" to make it more clear. There is an "alias" in the configuration and I put in "definition" for backward compatibility.

I tested it using YAML format and it seemed to be backward compatible in that case. Apparently, the GUI is a different story.

If you re-select your package from the dropdown, you should be able to get it working again, it just needs to map the value to the new name. If all else fails, I suggest adding a new task, copying all of your old settings over from the current task, and removing the current task.

Sorry, this is my first time messing around with an Azure DevOps task and the docs are pretty scarce on how updates work.

NightOwl888 commented 5 years ago

@renevanosnabrugge

After giving this a little thought, I suggest that you do this:

  1. Checkout the tag/commit of the previous release, and create a duplicate copy of it with a higher version number than the one you just released, but still at version 1.x.
  2. Release that package.
  3. Checkout the HEAD again with these changes, build it as version 2.x.
  4. Release that package as well.

That should prevent others from having issues with backward compatibility, and will give people a way to roll back if they need to. Currently there is nothing in the control panel that gives you that option, you are stuck on the last major version that was released. Since you have not bumped to 2.x yet, there is only one option.

SanderGcNL commented 5 years ago

@NightOwl888 Re-selecting the package does the trick. Downside is that i have to go through a whole lot of release definitions to re-select the packages. Looks like the GUI doesn't care much about aliases/ backwards compatibility ;)

@renevanosnabrugge I don't think so. I can't seem to activate any other task versions (from the GUI that is).

Thanks for the quick responses!

renevanosnabrugge commented 5 years ago

published a new major version and reverted changes in the 1.x version

NightOwl888 commented 5 years ago

Hmm..that didn't have the expected result.

image

Somehow 2.x still completely replaced 1.x. Maybe you are somehow supposed to package both 1.x and 2.x together.

renevanosnabrugge commented 5 years ago

No... only when you have installed 1.x.

I had a choice

Verstuurd vanaf mijn iPhone

Op 19 jul. 2019 om 22:11 heeft Shad Storhaug notifications@github.com<mailto:notifications@github.com> het volgende geschreven:

Hmm..that didn't have the expected result.

[image]https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F1538288%2F61562617-e4fdc580-aa9b-11e9-801d-b075e3e70553.png&data=02%7C01%7C%7C08ebde383cc540a3517f08d70c854a6b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636991638920130164&sdata=RYO3YmDKvyBnPx2dEddayZkUiiZJq02G35v7dw9whTw%3D&reserved=0

Somehow 2.x still completely replaced 1.x. Maybe you are somehow supposed to package both 1.x and 2.x together.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Frenevanosnabrugge%2Fvsts-promotepackage-task%2Fpull%2F25%3Femail_source%3Dnotifications%26email_token%3DABOH2WXJKFTFYHJ4XEMVALLQAINXFA5CNFSM4H3RAC3KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2MUR2A%23issuecomment-513362152&data=02%7C01%7C%7C08ebde383cc540a3517f08d70c854a6b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636991638920140170&sdata=Q7fZt2i4PV9eJvnr8oIaaLybp5PmIBz%2BEOZlmVwiMZI%3D&reserved=0, or mute the threadhttps://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABOH2WQIYEKI4G4E6SGW4K3QAINXFANCNFSM4H3RAC3A&data=02%7C01%7C%7C08ebde383cc540a3517f08d70c854a6b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636991638920150181&sdata=PZA8PebuFBi4bArdyPTjjzre56SgmRfZROrK%2FWxYeqY%3D&reserved=0.

SanderGcNL commented 5 years ago

This is exactly what i needed for compatibility. My existing definitions are now using 1.x which is working like a charm again.

I too am able to manually switch between 1.x and 2.x now.

A very big thanks to the both of you for the quick solution!

onurbiyik commented 4 years ago

Unfortunately, it isn't working on the Azure DevOps server. It is failing on the first REST call, Get-FeedId. I am not sure what the issue is because the original error message is not coming through the try/catch block. The error isn't happening when I run it locally using the $env:PAT variable - locally, it runs all the way through to the end.

We could run the extension on-premise and added pull request #37. Maybe this could be the reason why you had authentication problems.