Pipelines as in docs gives "The 'environment' section must be a map."

TacoV April 21, 2017

My Pipelines configuration gets rejected with the following message:

The 'environment' section in your bitbucket-pipelines.yml file must be a map.

Using the docs, I created the following yml:

pipelines:
  branches:
    main:
      - step:
          image: php
          script:
            - php -v
            - apt-get update && apt-get install -y unzip
            - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
            - composer -V
            - composer install
            - bin/console doctrine:schema:create
            - bin/console doctrine:fixtures:load
            - vendor/bin/phpunit
          services:
            - mysql
definitions:
  services:
    mysql:
      image: mysql
      environment:
        MYSQL_DATABASE: tournament
        MYSQL_RANDOM_ROOT_PASSWORD: yes
        MYSQL_USERNAME: tournament_user
        MYSQL_PASSWORD: tournament_password

What's wrong with this configuration file? Why is it rejected?

6 answers

1 accepted

1 vote
Answer accepted
TacoV April 24, 2017

USERNAME should be USER and the values should be encapsulated in apostrophes. This works:

      environment:
        MYSQL_DATABASE: 'tournament'
        MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
        MYSQL_USER: 'tournament_user'
        MYSQL_PASSWORD: 'tournament_password'
xtjhin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 26, 2017

Good catch

Adrian March 12, 2018

The validator at https://bitbucket-pipelines.prod.public.atl-paas.net/validator does not seem to catch that tho.

Like # people like this
Phil Manser July 10, 2018

I second @Adrian - the validator told me my configuration was valid but then I got this unexplained error.

Also, these docs should be updated to use the correct format https://confluence.atlassian.com/bitbucket/how-to-run-common-databases-in-bitbucket-pipelines-891130454.html

miqwit November 22, 2018
1 vote
TacoV April 24, 2017

I found the error! You shouldn't use MYSQL_USERNAME but MYSQL_USER!

kierenpitts April 24, 2017

Awesome, i'll check that out later.They also seem to have updated the docs as now the credentials are in quotes and they weren't before (still says MYSQL_USERNAME though)!

https://confluence.atlassian.com/bitbucket/test-with-databases-in-bitbucket-pipelines-856697462.html

xtjhin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 26, 2017

Very sorry about this. Good catch. I've updated it to MYSQL_USER

Thanks

1 vote
kierenpitts April 23, 2017

I had the same problem and through a process of elimination found that the error comes from using MYSQL_RANDOM_ROOT_PASSWORD. So, despite what the pipelines documentation says, I don't think this is supported properly yet.

I replaced:

MYSQL_RANDOM_ROOT_PASSWORD: yes

with:

MYSQL_ROOT_PASSWORD: some_password

Not ideal but it is a workaround for now.

xtjhin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 26, 2017

Hi Kieren, sorry for the incorrect example in the docs. I've gone ahead and fixed it.

It's an issue with yml where yes gets converted to a boolean (true) which messes with Pipelines since you can't have a boolean environment variable they must be strings.

If you wrap the yes in quotes then it should work.

MYSQL_RANDOM_ROOT_PASSWORD: 'yes'

kierenpitts April 29, 2017

Hi Joshua

Many thanks for this. Much appreciated.

Cheers

Kieren

0 votes
Allan Daly December 15, 2017

These answers were very helpful. Thanks everyone.

Team Atlassian -- the docs on the page at the link below are still incorrect -- need to add quotes around the environment variables and also use MYSQL_USER not MYSQL_USERNAME. Please fix these. Thx.

0 votes
TacoV April 24, 2017

Thanks, that worked!

It totally shouldn't have, since even the mysql docker docs acknowledge the random_root parameter, but hey, fine for now :)

0 votes
TacoV April 21, 2017

It also seems to fire on every commit, since the branch is called 'default', not 'main', but that is another issue for another time ^^.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events