Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to integrate pipes into a custom/parent pipe?

Hello,

we have a lot of microservice repositories. And we want to write a parent CI/CD pipe that we can reuse in any of these repositories to reduce the management effort if we have to adjust the CI/CD pipe. 

Based on the doc of writing a custom pipe (https://support.atlassian.com/bitbucket-cloud/docs/write-a-pipe-for-bitbucket-pipelines/) I'm understanding that I have to write shell or python scripts. But my use case is mostly writing a parent pipe that is including other pipes e.g. the sonarcloud pipe. And this standard pipe I can reuse in all my repositories. 

So my question is: How am I able to integrate other pipes into my parent pipe? 

1 answer

0 votes

Hi @Micha Mailänder . Thanks for you question. It's a good case to use trigger-pipeline pipe.
All you need is to use this pipe, pass credentials and specify the name of your repo. Example below: 

script:
  - pipe: atlassian/trigger-pipeline:4.2.1
    variables:
      BITBUCKET_USERNAME: $BITBUCKET_USERNAME
      BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
      REPOSITORY: 'your-awesome-repo'


Regards, Igor. 

Thanks for the reply @Igor Stoyanov 

But can I use that also that the triggered pipeline uses my current repository code as the base?

My understanding:

One repo = One pipe

If I run the pipe_1.yml that is included in repo_1 then it uses the data from repo_1. If I trigger pipe_2 (with the trigger-pipeline) of repo_2 then the pipe_2 uses the code of repo_2 and not from repo_1. Or do I misunderstand here something, and I can use pipe_2 to run it with the code of repo_1? 

@Micha Mailänder  As far as i understand, you can set 

REPOSITORY: 'your-awesome-repo'

with repo_1 or repo_2 in any repository where you want to trigger your pipeline.

Example: in repository repo_1 in pipe_1.yml you can set 

REPOSITORY: 'repo_2'

This is your case?

Regards, Igor.

Not sure if we're talking from the same :D

I try to explain it with the picture:

Pipeline.png

If I'm understanding you correctly, I can use the "trigger-pipeline" to call another pipeline.

  1. So I'm including in the bitbucket-pipelines.yml of Repository 1 only the trigger-pipeline. With the trigger-pipeline, I call Repository-2.
  2. The Repository-2 bitbucket-pipelines.yml is including the CI/CD pipeline script that I really want to run in Repository-1. 

My understanding is, the Repository-2 bitbucket-pipeline.yml would use now the code that is inside Repository-2. But instead, it should use the code of Repository-1.

So what do I have to do for that, that the Repository-2 bitbucket-pipelines.yml is used to run on the code of repository-1?

Hoping that this explanation is now more clear ;)

 

My understanding is, the Repository-2 bitbucket-pipeline.yml would use now the code that is inside Repository-2. But instead, it should use the code of Repository-1.  So what do I have to do for that, that the Repository-2 bitbucket-pipelines.yml is used to run on the code of repository-1?

 

@Micha Mailänder  If you want to use code of Repository-1 inside bitbucket-pipeline.yml of  Repository-2 you need to add this to bitbucket-pipeline.yml of  Repository-2:

script:
  - pipe: atlassian/trigger-pipeline:4.2.1
    variables:
      BITBUCKET_USERNAME: $BITBUCKET_USERNAME
      BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
      REPOSITORY: 'Repository-1'

without any changes in bitbucket-pipeline.yml of Repository-1

Regards, Igor.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
Community showcase
Published in Bitbucket

📣 Calling Bitbucket Data Center customers to participate in research

Hi everyone, Are you Bitbucket DC customer? If so, we'd love to talk to you! Our team wants to dive deep to understand your long-term plans regarding Bitbucket DC and Atlassian Cloud. Do you plan...

227 views 2 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you