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

Pipeline environment variable valid characters

We are getting the message, "A variable value contains an illegal string or character" from Bitbucket Pipeline.

The Environment Variable Document, unless I missed it, doesn't mention any limits on values.  It doesn't say anything about escaping characters in the values.

What characters are not valid?  Are there any escaping mechanisms?

4 answers

0 votes
davina Atlassian Team Jul 23, 2017

Hi Douglas,

If you scroll down on that documentation page to "User variables", you will see a few limitations:

  • Names can only contain ASCII letters, digits and underscores
  • Names are case-sensitive
  • Names can't start with a digit

Hope this helps!

Hey @davina I'm having exactly the same issue. I do not see any illegal characters on my env vars.


Opening the validator shows this:


Screenshot from 2017-07-30 16-20-40.png

I even tried to use the env vars without the double quotes to no avail, still getting this:


Screenshot from 2017-07-30 16-18-37.png

I do have, of course, the referenced variables defined in my environment variables page set.


Is this a known issue... something we are doing wrong perhaps?


I love to have the pipelines integrated with the source control but unfortunately storing the credentials on the YAML is not an option as you'd guess.


Thanks in advance!

Just to add to the conversation: using the ENV VARS within the pipelines section works; I added the following as the last command of the pipeline for instance:


echo "Database name is $DB_NAME"


And it does output in the log the database name, so it seems that only when using env vars in the definitions section they are not properly parsed:

Screenshot from 2017-07-30 17-33-39.png

davina Atlassian Team Jul 30, 2017

Hi @Gustavo Rubio,

Yes you're right, under our official documentation "Defining a service" you'll see:

Note - the environment section must contain only literal values, not environment variables.

I will raise a bug against the validator - it should say it is invalid.




Oh, snap!, I missed that but still, the validator should not be green as you say. Thanks for the quick response!

This problem had me confused for a while. Is it true that we cannot set env vars in the definitions with env vars from the pipeline settings? 

This is so unintuitive... Why would we use environment variables from Bitbucket, when we can't actually use them in the service definitions...

SERIOUSLY - Wasted a few hours on this ridiculousness..why would Atlassian do something awesome like create environmental variables and then NOT allow us to implement them in the entire YAML file?! And the ENTIRE documentation for bitbucket pipelines doesnt promote the use of the environmental variables...I'm about to switch to Gitlab where we don't have half-baked implementations and documentation ..

Like Herraiz Stéphane likes this

I'm confused, so what is the point of allowing us to create user-defined ENV vars is we can't actually use them? If anything using them in the pipelines.yml file seems like the ONLY place you would want to use them...

For real? I have more than 18 intents and then read this...

Suggest an answer

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

Atlassian supported Jenkins integration for Bitbucket Server

We’ve been building a plugin to integrate Bitbucket Server and Jenkins CI, and I’m excited to announce that our alpha is ready to download and install. It lets you seamlessly configure a Jenkins job ...

1,091 views 3 17
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