Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

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

Open
babygoat opened this issue Dec 19, 2019 · 0 comments

Comments

@babygoat
Copy link

babygoat commented Dec 19, 2019

Post on discuss forum as well.

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. Let me know if you need more informations for investigation. Thanks for your patience to read the post!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant