0

The below script is to trigger pipeline in Azure devops via REST, Its working fine on an existing pipeline, but when trying on newly created pipeline which has never ran then its throwing below error. Any help or suggestion would be really appreciated.

{"$id":"1","innerException":null,"message":"No pool was specified.\nUnexpected parameter 'pool'","typeName":"Microsoft.Azure.Pipelines.WebApi.PipelineValidationException, Microsoft.Azure.Pipelines.WebApi","typeKey":"PipelineValidationException","errorCode":0,"eventId":3000}
#!/bin/bash

echo "Enter PAT Token"
read -r PAT

echo "Enter Organization name"
read -r OrganizationName

echo "Enter Project ID"
read -r projectId

pipelineId=$(jq -r '.id' PipeOutput.txt)  #Get definition ID from external TXT file

"Trigger_Pipeline=$(curl --write-out "%{http_code}\n" -X POST -L \
-u  :"$PAT" "https://dev.azure.com/""${OrganizationName}""/""${projectId}""/_apis/pipelines/""${pipelineId}""/runs?api-version=6.0-preview.1" \
-H  "Content-Type: application/json" \
-H  "Accept: application/json" \
-d '{
    "resources": {
        "repositories": {
            "self": {
                "refName": "refs/heads/master"
            }
        }
    }
}' --output Triggeroutput.txt --silent)"
echo "Output: $(Trigger_Pipeline)"
Devops-Learner
  • 451
  • 1
  • 4
  • 16

1 Answers1

0

I tested this REST API with the newly created classic pipeline and YAML pipeline, it works fine on both pipelines.

For us to investigate this issue further, please share the YAML file of the newly created pipeline definition.

In addition, please also try with the following steps:

  • Try execute the REST API with another method to see if it work, such as on Postman client.
  • Try to manually trigger this new pipeline to see if it can work.
  • If the manual trigger works, try using the REST API trigger again.
Bright Ran-MSFT
  • 5,190
  • 1
  • 5
  • 12
  • Thats weird I just tested with postman and its failing for me now, I am using the example azure-pipeline.yaml code from MS azure `https://github.com/MicrosoftDocs/pipelines-java` – Devops-Learner May 17 '21 at 09:32
  • My Aim here is to write a BASH script to automate the Azure Devops, I have completed till creation stage, but when trying to trigger the newly created pipeline via REST its giving error. Through manual trigger its working fine, but when trying to run via rest its failing. Also if I run the pipeline manually and again then trigger the same script then its triggering the pipeline, but newly created ones are giving error – Devops-Learner May 17 '21 at 09:34
  • Hi @Vishal, What is the Region of the organization where the problem occurs on? You can go to **Organization Settings** > **Overview** to check the organization Region. Does the same issue occurs on your other organizations? – Bright Ran-MSFT May 18 '21 at 07:16
  • I am trying this in India region, haven't tried in any other region – Devops-Learner May 18 '21 at 11:57
  • Hi @Vishal, I tried the same REST API to trigger new pipelines in different organizations within different regions, but never reproduced the issue same as yours. Everything worked fine, all the pipeline can be triggered without any error. It's very odd why your issue occurs. – Bright Ran-MSFT May 26 '21 at 06:28