Unable to trigger pipeline to build forked Pull Request via V2 API, error message: *Branch not found*

Hi there,

I’m encountering problem when triggering a pipeline by v2 API endpoint, which returns error message of “Branch not found” with 400 status code. My goal is to setup a mono-repo with services in individual directories and triggering the workflow only when the services are modified. Thanks to the discussion forums , I found some helpful discussions and explanation which give me great heads up.

Here is a simpler version of the config snippet

version: 2.1
parameters:
    trigger:
      type: boolean
      default: true
    
    service1:
      type: boolean
      default: false
    
    service2:
      type: boolean
      default: false

jobs:
   trigger_pipelines:
     ...
     steps:
        - checkout
        - run:
            name: trigger service workflow if modified
             command: |
                // Filter the modified service
                ...
                // trigger modified service workflow 
                curl -u "${CIRCLE_TOKEN}:" \
                       -H "Content-Type: application/json"
                       -d "{\"branch\": \"$CIRCLE_BRANCH\", \"parameters\": {...} }" \
                       https://circleci.com/api/v2/project/gh/org/repo/pipeline

workflows:
    version: 2
    
    analysis:
        when: << pipeline.parameters.trigger >>
        jobs:
           - trigger_pipelines

        service1:
            when: << pipeline.parameters.service1 >>
            ...
        service2:
            when: << pipeline.parameters.service2 >>
            ...

The default workflow(analysis) was triggered from a forked Pull Request (I switch on the setting Build forked pull requests) which created a pull/1 branch on the CircleCI server. However, when the changes of service1 workflow was detected and triggered by the POST /pipeline endpoint, I got the error message “Branch not found” in the build step terminal. I also tried to try to POST the endpoint through postman to ensure the branch value equals to pull/1 but the same error remained. I was wondering if I missed something in the document. Thanks for your patience to read the post!

Hi & welcome to our discuss community!

I’m afraid triggering pipelines for PRs is not currently supported. Please can you add your vote / comment to the feature request listed here: https://ideas.circleci.com/ideas/CCI-I-1280

Thanks for pointing out! I have voted the idea. Does it stand for the feature not currently on the roadmap of the V2 API?

I don’t think that is currently on the roadmap, no – but if that becomes a popular feature request, who knows? :slight_smile:

Can you confirm if these ideas have already been implemented?