You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to authenticate using an Authentication HTTP header build manually using $env:SYSTEM_ACCESSTOKEN and using Invoke-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:
tbolon
changed the title
How to authenticate using accesstoken to call devops API from custom Powershell task
How to authenticate using AccessToken to call DevOps API from custom PowerShell task
Apr 2, 2024
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: