How can I use trigger pipeline to automatically launch a specific step in the other repository?
Asked by yosser_mahfoudh:

How can I use trigger pipeline to automatically launch a specific step in the other repository ,

for example, I have repo A and repo B. I added the trigger pipeline pipe in the repository A and I want to autpmaticcaly trigger repo B with a specific step.

repo B contains default step which is launched auto when there is any new commits in the branch, patch and unit test steps.


Answers:
author: Patrik S
body: Hello [@yosser_mahfoudh](/t5/user/viewprofilepage/user-id/3803216) and thank you for reaching out to Community!

You can have multiple pipelines defined in the same YML file that are [triggered differently](https://support.atlassian.com/bitbucket-cloud/docs/pipeline-start-conditions/) (default pipeline, branch pipeline, pull-request pipeline). When using the pipe **[atlassian/trigger-pipeline](https://bitbucket.org/atlassian/trigger-pipeline/src/master/)**you need to define which pipeline of the repo B you want to trigger, and this is configured through the variables REF_TYPE and REF_VALUE provided in the pipe's configuration.

For the use-case in your description, where from repo A you want to trigger the **default** pipeline in repo B, the following pipe definition would work :  

```
          - pipe: atlassian/trigger-pipeline:5.3.0
            variables:
              BITBUCKET_USERNAME: $BB_USERNAME
              BITBUCKET_APP_PASSWORD: $BB_APP_PASS
              REPOSITORY: 'repoB'
              REF_TYPE: 'branch'
              REF_NAME: 'master'
              WAIT: 'true'
```

Ref_name is the name of the branch you want the pipeline to run against. In this example, we are triggering the **default** pipeline in repo B to run against the latest commit in the branch **master**.

It's important to note that if you have defined a [branch-triggered pipeline](https://support.atlassian.com/bitbucket-cloud/docs/pipeline-start-conditions/#Branches) in your YML file of repo B for branch **master** (or any other name you provide in REF_NAME), the branch pipeline will get prioritized over the **default** pipeline.

Hope that helps to clarify your question! If anything is not clear, feel free to ask!

Thank you, [@yosser_mahfoudh](/t5/user/viewprofilepage/user-id/3803216) !

Patrik S

comments: author: Erkan Sahin
body: How can I launch a specific step in the repoB repository?

There are different steps in repoA.


author: Patrik S
body: Hello [@Erkan Sahin](/t5/user/viewprofilepage/user-id/5378496) ,

It's not possible to launch only one step of a pipeline. The **[atlassian/trigger-pipeline](https://bitbucket.org/atlassian/trigger-pipeline/src/master/)**pipe will trigger a pipeline and all the steps defined under that pipeline.

What you can do is create a pipeline with only one step, and then trigger that pipeline using the instructions above.

```
pipelines:
  branches:
    hotfix/*: # this is a branch pipeline and contains multiple steps
      - step:
          name: Build hotfix
          script:
            - echo "Hello, hotfix!"
      - step:
          name: Test hotfix
          script:
            - echo "Testing hotfix"

  default: # this is the default pipeline and it contains just 1 step
    - step:
        name: All other builds
        script:
          - echo "Hello, World!"
```


author: Linh.Nguyen
body: hi [@Patrik S](/t5/user/viewprofilepage/user-id/4603309) I just one trigger run after test execution getting failed, but now it triggers forever

For example, build 1 get failed, new auto trigger comes (build 2), build 2 gets failed, new auto trigger comes (build 3)....it doesn't stop

please help


author: Patrik S
body: Hello [@Linh_Nguyen](/t5/user/viewprofilepage/user-id/4963009) ,

Do you mean that the pipeline in the parent repo keeps triggering the pipeline on the second repo multiple times even after the pipeline on the second repo has failed?

Could you share with us the pipeline YML of both the parent and second repo?

Thank you, [@Linh_Nguyen](/t5/user/viewprofilepage/user-id/4963009)


Tags: bitbucket-cloud

bitbucket-pipelines

cloud

trigger