Community Center | Not monitored
Tag not monitored by Microsoft.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I want to trigger a pipeline using invoke-Rest Method call from powershell task of yml pipeline, but i am getting access denied error like below.
Access denied. DS
| Common Build Service (xxxxx) needs Queue builds permissions for
| build pipeline xxxx:xxxxxxx in
| team project xxxxxxx to perform the action. For more information,
| contact the Azure DevOps
Here is the code that I am using:
- task: PowerShell@2
enabled: true
inputs:
targetType: 'inline'
script: |
$definitionId = xxxxx
$organization = "xxxx"
$project = "xxxxx"
$body = @{
resources = @{
pipelines = @{
pipeline = $definitionId
refName = "refs/heads/xxxxx" # Branch to trigger the pipeline
}
}
} | ConvertTo-Json
$url = "https://dev.azure.com/$organization/$project/_apis/build/builds?definitionId=xxxxx&api-version=7.0"
Write-Host "URL: $url"
$pipeline = Invoke-RestMethod -Uri $url -Headers @{
Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"
"Content-Type" = "application/json"
} -Method Post -Body $body
Write-Host "Pipeline = $($pipeline | ConvertTo-Json -Depth 100)"
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
Here I am using "system.AccessToken" as PAT token.
What will be the cause of the access denied failure...can someone guide me.
Tag not monitored by Microsoft.