How to see variables inside ' ' ?

Carmen Carrero July 21, 2023

Hello, 

I'm using bitbucket pipelines and I need to use the value of a variable but inside of ''. 

For example, I want the following: 'environment=dev' and dev is the environmentValue variable.

If I write 'environment=$environmentValue' the result is 'environment=$environmentValue' and not 'environmnet=dev'. 

However, if I write echo $environmentValue the result is dev, so I think the error is '' but I need write it with the ''.

 

Thank you!!

1 answer

1 accepted

2 votes
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 24, 2023

Hi Carmen and welcome to the community!

Everything you put inside single quotes gets interpreted literally, so variables are not substituted. This is a feature of the shell and not specific to Pipelines, please see here for reference:

Variables are substituted inside double quotes. If you use

echo "'environment=$environmentValue'"

you are going to get

'environmnet=dev'

Is this something that works for you?

Kind regards,
Theodora

Carmen Carrero August 3, 2023

Yes!!! Thank you :D

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

You are very welcome! Please feel free to reach out if you ever need anything else! :)

Suggest an answer

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

Atlassian Community Events