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

How to integrate pipes into a custom/parent pipe?

Micha Mailänder September 17, 2021

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
Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 17, 2021

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. 

Micha Mailänder September 18, 2021

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? 

Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 19, 2021

@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.

Micha Mailänder September 20, 2021

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 ;)

Igor Stoyanov
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 20, 2021

 

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
AUG Leaders

Atlassian Community Events