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

Using YAML anchors in multiple steps

warmannj November 9, 2019

HI,

My pipeline has multiple steps and I'm trying to get it to work for multiple environments. It was working fine for one environment.  I already followed the guide in this document: https://confluence.atlassian.com/bitbucket/yaml-anchors-960154027.html?_ga=2.260751877.964504472.1573266564-336097571.1573266564

But it doesn't appear to be correct as I get the error: `There is an error in your bitbucket-pipelines.yml at [pipelines > branches > develop > 0]. To be precise: Step is empty, null, or missing.`, when following the syntax in the example directly.

 

Here's my pipeline yml file:

image: atlassian/default-image:2

definitions:
  steps:
  - step: &pushToECR
  name: Push to ECR
  script:
    - unset NPM_CONFIG_USER
    - docker build -t $ECR_IMAGE_NAME .
    - pipe: atlassian/aws-ecr-push-image:1.0.1
    variables:
      AWS_ACCESS_KEY_ID: '$AWS_ACCESS_KEY_ID'
      AWS_SECRET_ACCESS_KEY: '$AWS_SECRET_ACCESS_KEY'
      AWS_DEFAULT_REGION: '$AWS_REGION'
      IMAGE_NAME: '$ECR_IMAGE_NAME'

- step: &deployToECS
name: Deploy to ECS
deployment: development
services:
- docker
script: # Modify the commands below to build your repository.
- pipe: atlassian/aws-ecs-deploy:1.0.4
  variables:
    AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
    AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
    AWS_DEFAULT_REGION: $AWS_REGION
    CLUSTER_NAME: '$ECS_CLUSTER_NAME'
    SERVICE_NAME: '$ECS_SERVICE_NAME'
    TASK_DEFINITION: '$ECS_TASK_DEFINITION_FILE'
    DEBUG: 'true'

pipelines:
  branches:
    develop:
      - step:
        <<: *pushToECR
        deployment: development
   - step:
     <<: *deployToECS
     deployment: development

1 answer

0 votes
Rupert Broad August 20, 2020

A little difficult to tell if the problem is with your yaml formatting - it's all out of whack - or the code itself. I would guess the issue is that you haven't declared "deployment" in your pushtoEcr definition.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events