-
Notifications
You must be signed in to change notification settings - Fork 274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to authenticate using AccessToken to call DevOps API from custom PowerShell task #1031
Comments
Hi @tbolon, thank you for your question! We'll take a look at this soon. |
Hi @tbolon
|
Hi @tbolon! I'll close this issue since it seems to be resolved. If you still have this problem, feel free to re-open. |
Hello @aleksandrlevochkin and @DenisNikulin5, sorry for not replying ealrier, I was sure I had answered your suggestion. This comment does not work, because you imply that I want to use a powershell script. But in my case I want to create a powershell custom task, and I can't access variables inside my custom script. |
Environment
azure-pipelines-task-lib version: 4.10.1
Issue Description
Hi,
I want to create a custom PowerShell task to promote packages uploaded to Azure Artifacts automatically during the build pipeline.
I have successfully created a custom task, but I can't find a way to authenticate my request.
I have found a similar issue #579 but for the typescript language.
I build the url using the environment variables, which works:
$url = "$($env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI)_apis/packaging/feeds/$feedName/nuget/packages/" + $pkgName + "/versions/" + $pkgVersion + "?api-version=7.0"
I wanted to authenticate using an
Authentication
HTTP header build manually using$env:SYSTEM_ACCESSTOKEN
and usingInvoke-RestMethod
but it seems the access token is not available in the scope of the custom task.How am I supposed to call the Azure DevOps server API from inside a PowerShell custom task?
I did not find an existing task doing the same using PowerShell.
There seems to exists a VSTS .NET Library wrapper, but I am not sure I can easily PATCH the package version to publish it to a field, and I can not find how I am supposed to import this library.
The text was updated successfully, but these errors were encountered: