How can I use deployments with shared pipeline and use deployment with importing particular steps

Hareesh Kanchala November 28, 2023

I have a shared pipeline created for all my microservices, the steps are more or less same but vary on branch execution. with different variable set. How can I achieve below functionality

Example:

**********************************************************

Shared Pipeline

***********************************************************

export: true

definitions:
  pipelines:
    share-pipeline-java8: &share-pipeline-java8
      - step: &Maven-Build-and-Test
          image:
            name: abc.io/maven:3.9-jdk8
            username: $ART_USER
            password: $ARTI_PASSWORD
          caches:
            - maven
          script:
            - mvn clean install
          artifacts:
            - target/*.jar
          after-script:
              # Collect checkstyle results, if any, and convert to Bitbucket Code Insights.
            - pipe: atlassian/checkstyle-report:0.3.0

 

 

**********************************************************************

Import Pipeline

***************************************************************************

pipelines:
  branches:

    develop:
     import: xyz:develop:share-pipeline-java8
     deployment: develop
     step: *Maven-Build-and-Test

    master:
     import: xyz:master:share-pipeline-java8
     deployment: production
     step: *Maven-Build-and-Test

 

2 answers

1 vote
Caterina Curti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 2, 2024

Hi @Hareesh Kanchala,

Now that Dynamic Pipelines have been released, you can achieve a greater level of flexibility with the Bitbucket pipelines.

Last week, I published this article explaining how to add a step dynamically to a repository. This approach offers a greater level of flexibility, considering that the app logic can change the entire pipeline of a repository.


Hope this will help managing pipelines,
Caterina

1 vote
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 4, 2023

Hi Hareesh and welcome to the community!

I'm afraid that it is not possible to share only certain steps at the moment or customize elements like deployments.

We have a feature request for the ability to share certain steps of a pipeline:

You can add your vote and feedback to that ticket to express your interest.

In the meantime, you can achieve what you want by creating a separate pipeline for each combination of pipeline step and deployment environment in the shared pipeline, and then use them in the imported repo.

We have the following documentation on sharing pipelines configuration that also includes many frequently asked questions:

Please feel free to reach out if you have any other questions!

Kind regards,
Theodora

Hareesh Kanchala December 11, 2023

Hi Theodora, Thanks for getting back. In that case Can we do the same for import pipelines with a deployment in that case?

pipelines:
  branches:
    hareesh/multi_branch_shared_pipeline:
     deployment: Develop
     import: abc:hareesh/xyz:share-pipeline
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 11, 2023

Hi Hareesh,

A deployment is a property of a step or a stage and not of the whole pipeline. I'm afraid that you cannot use a definition like the one you shared. You will need to define the deployment in the Shared Pipeline repo, in the specific step that uses a deployment, as follows:

export: true

definitions:
pipelines:
share-pipeline-java8-production:
- step: &Maven-Build-and-Test
deployment: develop
image:
name: abc.io/maven:3.9-jdk8
username: $ART_USER
password: $ARTI_PASSWORD
caches:
- maven
script:
- mvn clean install
artifacts:
- target/*.jar
after-script:
# Collect checkstyle results, if any, and convert to Bitbucket Code Insights.
- pipe: atlassian/checkstyle-report:0.3.0

If you have more than one deployment environment that you want to use this way, you will need to add separate definitions for the same step with a different deployment environment.

Please feel free to let me know if you have any questions.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events