# BuildEnvironmentVariable

- Source: [`aws-codebuild/lib/project.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-codebuild/lib/project.ts#L2365)

## Example

```ts
const sourceOutput = new codepipeline.Artifact();
const buildAction = new codepipeline_actions.CodeBuildAction({
  actionName: 'Build1',
  input: sourceOutput,
  project: new codebuild.PipelineProject(this, 'Project', {
    buildSpec: codebuild.BuildSpec.fromObject({
      version: '0.2',
      env: {
        'exported-variables': [
          'MY_VAR',
        ],
      },
      phases: {
        build: {
          commands: 'export MY_VAR="some value"',
        },
      },
    }),
  }),
  variablesNamespace: 'MyNamespace', // optional - by default, a name will be generated for you
});

// later:
declare const project: codebuild.PipelineProject;
new codepipeline_actions.CodeBuildAction({
  actionName: 'CodeBuild',
  project,
  input: sourceOutput,
  environmentVariables: {
    MyVar: {
      value: buildAction.variable('MY_VAR'),
    },
  },
});
```

## Properties

- `type`: [BuildEnvironmentVariableType](/cdk/api/v2/docs/aws-cdk-lib.aws_codebuild.BuildEnvironmentVariableType.html) = PlainText — The type of environment variable.

- `value`: any (required) — The value of the environment variable.

  For plain-text variables (the default), this is the literal value of variable.
  For SSM parameter variables, pass the name of the parameter here (`parameterName` property of `IParameter`).
  For SecretsManager variables secrets, pass either the secret name (`secretName` property of `ISecret`)
  or the secret ARN (`secretArn` property of `ISecret`) here,
  along with optional SecretsManager qualifiers separated by ':', like the JSON key, or the version or stage
  (see https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html#build-spec.env.secrets-manager for details).
