BitBucket Pipeline unexpected EOF while looking for matching `"' Edited

Good day,

Hi guys, please help me, Ive been trying to get pipeline work with ECS by using tutorial from atlassian link here, and manage to be able to get the docker image through to ECR.

But it just keep failing when executes export TASK_VERSION command, below is the error message, I have tried to find this missing `"' but I havent found it yet. I also include my bitbucket-pipeline.yml & Dockerfile. Thanks in advance. 

Error message :

+ export TASK_VERSION=$(aws ecs register-task-definition --family test_ecs_dev --container-definitions "[{\"name\":\"test_ecs_container\",\"image\":\"$IMAGE_NAME",\"cpu\":10,\"command\":[\"echo\",\"hello\"],\"memory\":10,\"essential\":true}]")
bash: /opt/atlassian/pipelines/agent/tmp/bashScript2767235545855639452.sh: line 81: unexpected EOF while looking for matching `"' 

Build log screenshot :

Screen Shot 2017-07-01 at 4.23.41 AM.png

bitbucket-pipeline.yml & Dockerfile :

# This is a sample build configuration for Go.
# Check our guides at https://confluence.atlassian.com/x/5Q4SMw for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: golang:1.8

pipelines:
  default:
    - step:
        script: # Modify the commands below to build your repository.
          - PACKAGE_PATH="${GOPATH}/src/bitbucket.org/${BITBUCKET_REPO_OWNER}/${BITBUCKET_REPO_SLUG}"
          - mkdir -pv "${PACKAGE_PATH}"
          - tar -cO --exclude-vcs --exclude=bitbucket-pipelines.yml . | tar -xv -C "${PACKAGE_PATH}"
          - cd "${PACKAGE_PATH}"
          - go get -v
          - go build -v
          - go test -v
          - export IMAGE_NAME=irahardianto/test_ecs:$BITBUCKET_COMMIT
          # build the Docker image (this will use the Dockerfile in the root of the repo)
          - docker build -t $IMAGE_NAME .
          # authenticate with the Docker Hub registry
          - docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD
          # push the new Docker image to the Docker registry
          - docker push $IMAGE_NAME
          - curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
          - apt-get update -y
          - apt-get upgrade -y
          - apt-get install -y jq zip unzip
          - unzip awscli-bundle.zip
          - ./awscli-bundle/install -b ~/bin/aws
          - export PATH=~/bin:$PATH
          - $(aws ecr get-login --no-include-email --region ap-southeast-1)
          - docker tag $IMAGE_NAME 047415648520.dkr.ecr.ap-southeast-1.amazonaws.com/test_ecs:latest
          - docker push 047415648520.dkr.ecr.ap-southeast-1.amazonaws.com/test_ecs:latest
          # register the ECS task definition and capture the version
          - export TASK_VERSION=$(aws ecs register-task-definition --family test_ecs_dev --container-definitions "[{\"name\":\"test_ecs_container\",\"image\":\"$IMAGE_NAME",\"cpu\":10,\"command\":[\"echo\",\"hello\"],\"memory\":10,\"essential\":true}]" | jq --raw-output '.taskDefinition.revision')
          - echo "Registered ECS Task Definition:" $TASK_VERSION
          # Update the ECS service to use the updated Task version
          - aws ecs update-service --cluster test-ecs-cluster --service test_ecs_service --task-definition test_ecs_dev:$TASK_VERSION

options:
  docker: true
FROM golang:wheezy

# Create app directory
RUN mkdir -p /go/src/app
WORKDIR /go/src/app

COPY . /go/src/app/

EXPOSE 8000

WORKDIR /go/src/app
CMD ["go run", "hello.go"]

 

 

1 answer

0 vote

Hey @ichsan, funnily enough I'm working on an update for this tutorial at the moment.

There's a missing \ 

 

------------------------------------------------here-----|
V
"[{\"name\":\"test_ecs_container\",\"image\":\"$IMAGE_NAME"
,\"cpu\":10,\"command\":[\"echo\",\"hello\"],\"memory\":10,\"essential\":true}]"   

you can copy the task from here: 

- export TASK_VERSION=$(aws ecs register-task-definition
--family test_ecs_dev
--container-definitions
"[{\"name\":\"test_ecs_container\",\"image\":\"$IMAGE_NAME\",\"cpu\":10,\"command\":[\"echo\",\"hello\"],\"memory\":10,\"essential\":true}]"
| jq --raw-output '.taskDefinition.revision')

or for my preference of formatting

- export TASK_VERSION=$(aws ecs register-task-definition 
--family test_ecs_dev
--container-definitions
'[{"name":"test_ecs_container","image":"'"$IMAGE_NAME"'","cpu":10,"command":["echo","hello"],"memory":10,"essential":true}]'
| jq --raw-output '.taskDefinition.revision')

I'll update the documentation to fix it - thanks for raising the question :)

Seb

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

23,165 views 26 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you