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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,466,505
Community Members
 
Community Events
176
Community Groups

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

Atlassian Community Events