dbcs
dbcs

Reputation: 21

Creating a single bitbucket-pipelines.yml file for multiple projects

I have a large number of microservices (40+) with identical pipeline requirements (currently very simple: build, test, deploy). Each of them lives in its own repository. Obviously, I would like to avoid having to change my bitbucket-pipelines.yml file in 40 places as we improve our pipeline. I know travis and gitlab both offer an import/include feature that allows you to include a 'master' yml file. Is there anything similar for Bitbucket Pipelines? If not, what alternatives are viable?

Thanks!

Upvotes: 2

Views: 8767

Answers (3)

Alex
Alex

Reputation: 5982

You can use Share Pipelines Configurations feature that

allows you to define and share pipeline definitions within the same workspace, which enables you to streamline your pipeline definitions by not having to repeatedly create each pipeline configuration.

Define pipeline in one repo

export: true

definitions:
  pipelines:
    common-pipeline:
      - step:
         ...
        

and then use it in other repos

pipelines:
  default:
    import: shared-pipelines:main:common-pipeline

where shared-pipelines is a repo slug in the same workspace.

Upvotes: 1

Victor.Uduak
Victor.Uduak

Reputation: 2824

This works for me, I had to setup bitbucket pipeline for a solution with multiple projects.

You will have to add custom: after pipeline: attribute before the name of the pipeline

pipelines:
 custom:
 deployAdminAPI:
     - step:
         name: Build and Push AdminAPI
         script: enter your script
 deployParentsAPI:
     - step:
         name: Build and Push ParentsAPI
         script: enter your script

Here is the Link to the Solution on Bitbucket

Upvotes: -1

Alexander Zhukov
Alexander Zhukov

Reputation: 4557

You should be able to do that by using a custom Bitbucket Pipe. For example, you can build a custom pipe to deploy your code and add it to your bitbucket-pipelines.yml. Here is an example:

pipelines:
  default:
    - step:
        name: "Deployment step"
        script:
          - pipe: your-bitbucket-account/deploy-pipe:1.0.0
            variables:
              KEY: 'value'

Here is a link to an article that explains how to write a custom pipe https://bitbucket.org/blog/practice-devops-with-custom-pipes-reusing-ci-cd-logic

Upvotes: 3

Related Questions