Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

yosser_mahfoudh November 27, 2023

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.

 

1 answer

2 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 28, 2023

Hello @yosser_mahfoudh and thank you for reaching out to Community!

You can have multiple pipelines defined in the same YML file that are triggered differently (default pipeline, branch pipeline, pull-request pipeline). When using the pipe atlassian/trigger-pipeline 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 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 !

Patrik S

Erkan Sahin
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 4, 2023

How can I launch a specific step in the repoB repository?

There are different steps in repoA.

Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 5, 2023

Hello @Erkan Sahin ,

It's not possible to launch only one step of a pipeline. The atlassian/trigger-pipeline 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!"
Linh.Nguyen
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 29, 2024

hi @Patrik S 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

Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 30, 2024

Hello @Linh_Nguyen  ,

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 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events