How to use pipe in yaml anchors? Need help with refactor

Deleted user March 10, 2023

Hello All,

I have below parallel step, I want to refactor the same to reduce the number of lines in bitbucket-pipelines.yml

      - parallel:
          - step:
              name: Deploy Identity Service Main to Feature
              script:
                - echo "deploy identity service"
                - export SERVICE_TO_DEPLOY=identityservice
                - echo "Deploy service ${SERVICE_TO_DEPLOY}"
                - pipe: atlassian/trigger-pipeline:5.1.0
                  variables:
                    BITBUCKET_USERNAME: $BB_INTEGRATION_USER
                    BITBUCKET_APP_PASSWORD: $BB_INTEGRATION_TOKEN
                    REPOSITORY: ${SERVICE_TO_DEPLOY}
                    REF_TYPE: "branch"
                    REF_NAME: "pipelines"
                    CUSTOM_PIPELINE_NAME: "main-to-feature-deploy"
                    PIPELINE_VARIABLES: >
                      [{
                        "key": "BRANCH_TO_DEPLOY",
                        "value": "${BITBUCKET_BRANCH}"
                      },
                      {
                        "key": "SOURCE_REPO_NAME",
                        "value": "$BITBUCKET_REPO_SLUG"
                      }]
                    WAIT: "true"
          - step:
              name: Deploy Admin Service Main to Feature
              script:
                - echo "deploy admin service"
                - export SERVICE_TO_DEPLOY=adminservice
                - echo "Deploy service ${SERVICE_TO_DEPLOY}"
                - pipe: atlassian/trigger-pipeline:5.1.0
                  variables:
                    BITBUCKET_USERNAME: $BB_INTEGRATION_USER
                    BITBUCKET_APP_PASSWORD: $BB_INTEGRATION_TOKEN
                    REPOSITORY: ${SERVICE_TO_DEPLOY}
                    REF_TYPE: "branch"
                    REF_NAME: "pipelines"
                    CUSTOM_PIPELINE_NAME: "main-to-feature-deploy"
                    PIPELINE_VARIABLES: >
                      [{
                        "key": "BRANCH_TO_DEPLOY",
                        "value": "${BITBUCKET_BRANCH}"
                      },
                      {
                        "key": "SOURCE_REPO_NAME",
                        "value": "$BITBUCKET_REPO_SLUG"
                      }]
                    WAIT: "true"

1 answer

1 accepted

1 vote
Answer accepted
Deleted user March 10, 2023

Got the answer from this issue.

My code is as below

Definitions:

definitions:
  services:
    docker:
      memory: 1536

  pipes:
    - pipe: &triggerpipeline
        pipe: atlassian/trigger-pipeline:5.1.0
        variables:
          BITBUCKET_USERNAME: $BB_INTEGRATION_USER
          BITBUCKET_APP_PASSWORD: $BB_INTEGRATION_TOKEN
          REPOSITORY: ${SERVICE_TO_DEPLOY}
          REF_TYPE: "branch"
          REF_NAME: "pipelines"
          CUSTOM_PIPELINE_NAME: "main-to-feature-deploy"
          PIPELINE_VARIABLES: >
            [{
              "key": "BRANCH_TO_DEPLOY",
              "value": "${BITBUCKET_BRANCH}"
            },
            {
              "key": "SOURCE_REPO_NAME",
              "value": "$BITBUCKET_REPO_SLUG"
            }]
          WAIT: "true"

And parallel steps:

      - parallel:
          - step:
              name: Deploy Identity Service Main to Feature
              script:
                - echo "deploy identity service"
                - export SERVICE_TO_DEPLOY=identityservice
                - echo "Deploy service ${SERVICE_TO_DEPLOY}"
                - *triggerpipeline

          - step:
              name: Deploy Admin Service Main to Feature
              script:
                - echo "deploy admin service"
                - export SERVICE_TO_DEPLOY=adminservice
                - echo "Deploy service ${SERVICE_TO_DEPLOY}"
                - *triggerpipeline

Suggest an answer

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

Atlassian Community Events