Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to declare variables in yml file?


I set variables on "Add variables" and write it, but I was failed run pipeline.

for example,

> Add variables


> yml file

- IMAGE="$ACCOUNT_ID.dkr.ecr.$"

> build console message

The push refers to repository [$ACCOUNT_ID.dkr.ecr.$]

1 answer

1 accepted

0 votes
Answer accepted


I would like to ask a few questions so we can better help you:

1. Are the variables ACCOUNT_ID and AWS_REGION defined as Workspace variables?
Or as Repository variables? Or as Deployment variables?

2. Are these variables Secured? If you have defined them as Secured variables, then their value will not be displayed in the Pipelines log.

3. If I understand correctly, you define another variable named IMAGE in your yml file. The definition you used should work.

- Are you then using the variable IMAGE in the same pipelines step where you define it?
- Could you let us know what command in your script uses this variable, and also the full output of the command that fails? (Please feel free to sanitize any sensitive/private data from the output prior to sharing it here)

Kind regards,

Thank you @Theodora Boudale 

1. I defined Repository variables.

2. It was secured, and same pipeline

3. In bitbucket-pipelines.yml, it used define and not fail under example

- aws configure set aws_secret_access_key "${AWS_SECRET_ACCESS_KEY}"

- error script


IMAGE="${ACCOUNT_ID}.dkr.ecr.${AWS_REGION}"    <1s

4. conclusion

so, I want to define like this,

- IMAGE="${ACCOUNT_ID}.dkr.ecr.${AWS_REGION}",

but it was failed.

All variables are secured.

I wonder, it was correct expression like this, when I define Repository variables on yml.

- ${ACCOUNT_ID} in script

- "${ACCOUNT_ID}" in string


Thank you for the info.

The way you declare the variable is correct. Either of the following should work:

- IMAGE="$ACCOUNT_ID.dkr.ecr.$"


In the build log, you see the following:

IMAGE="${ACCOUNT_ID}.dkr.ecr.${AWS_REGION}" <1s

because the variables ACCOUNT_ID and AWS_REGION are Secured. When you have Secured variables, their values will be masked/hidden like this in the Build log.

However, their values are still used when you define IMAGE; they are masked in the build log because they are Secured variables, but their values are used in the definition of IMAGE.

You can confirm this the following way:

After you define the IMAGE variable in the yml, add another command

- echo $IMAGE > artifact.txt

and then define the file artifact.txt as an artifact in that step, e.g.

- step:
- echo $IMAGE > artifact.txt
- artifact.txt

After you run a build, download the file artifact.txt from the tab Artifacts next to the Build log, and you should see the value of IMAGE in there. (Please keep in mind that the file artifact.txt can be downloaded by anyone with access to your repo)

Is it clear why this is occurring?

If you still have questions, please feel free to let me know.

Kind regards,

Like KIM JEONG JIN likes this

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

📣 Calling Bitbucket Data Center customers to participate in research

Hi everyone, Are you Bitbucket DC customer? If so, we'd love to talk to you! Our team wants to dive deep to understand your long-term plans regarding Bitbucket DC and Atlassian Cloud. Do you plan...

182 views 2 4
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you