Mayank
Mayank

Reputation: 1392

AWS CodeBuild - BuildSpec.yml - exported-variables are not resolving values

I am trying to export a variable value from the CodeBuild Stage of AWS code-pipeline but the value is not resolving

Note: Windows container's PowerShell is executing the commands of buildspec.yml

Example: I am setting an Input environment variable named Client like below in the AWS CodeBuild project

enter image description here

and to export the same value I have modified my buildspec.yml like below

version: 0.2

env:
  variables:
    ClientEnv: $(echo $Client)
  exported-variables:
    - ClientEnv

but the exported value is expression not the resolved value

enter image description here

I have also tried passing variables but seems not working.

How I can pass the environment variables to exported-variables in such a scenario

Thanks in advance.

Upvotes: 0

Views: 6410

Answers (3)

SSG
SSG

Reputation: 314

If the name of the variable is Client as defined in the Env. Vars of CodeBuild project thenthe following is enough. You dont need to redefine the same variable in the env->variables section

env:
   exported-variables:
   - Client

Upvotes: 0

Igor Gassmann
Igor Gassmann

Reputation: 182

You need to change your code as is:

env:
  exported-variables:
    - Client

Upvotes: 1

Jyothish
Jyothish

Reputation: 1133

Simply use ${Client} in your buildspec.yml file

Upvotes: 0

Related Questions