aws-cdk icon indicating copy to clipboard operation
aws-cdk copied to clipboard

can not initialize EnvironmentVariables

Open bruce-igaw opened this issue 6 years ago • 2 comments

how to initialize EnvironmentVariables in codebuild project?

Reproduction Steps

var project = new PipelineProject(this, "Build", new PipelineProjectProps
{
	ProjectName = "BuildTest",
	BuildSpec = BuildSpec.FromSourceFilename("buildspec.yml"),
	Environment = new BuildEnvironment
	{
		BuildImage = LinuxBuildImage.FromDockerRegistry("mcr.microsoft.com/dotnet/core/sdk:3.1"),
		EnvironmentVariables = new Dictionary<string, BuildEnvironmentVariable>
		{
			["PROJECT_DIR"] = new BuildEnvironmentVariable { Value = "myproject", Type = BuildEnvironmentVariableType.PLAINTEXT }
		}
	}
});

Error Log

Implicitly type 'System.Collections.Generic.Dictionary <string, Amazon.CDK.AWS.CodeBuild.BuildEnvironmentVariable>' type 'System.Collections.Generic.IDictionary <string, Amazon.CDK.AWS.CodeBuild.IBuildEnvironmentVariable>' Could not convert to There is an explicit conversion. Make sure you have a cast.

Environment

  • CLI Version : aws-cli/1.16.83 Python/3.7.2 Windows/10 botocore/1.12.73
  • Framework Version: dotnet 3.1.100 / Amazon.CDK.AWS.CodeBuild v.1.18.0
  • OS : windows
  • Language : c#

Other


This is :bug: Bug Report

bruce-igaw avatar Dec 12 '19 08:12 bruce-igaw

@bruce-igaw try


var project = new PipelineProject(this, "Build", new PipelineProjectProps
{
    ProjectName = "BuildTest",
    BuildSpec = BuildSpec.FromSourceFilename("buildspec.yml"),
    Environment = new BuildEnvironment
    {
        BuildImage = LinuxBuildImage.FromDockerRegistry("mcr.microsoft.com/dotnet/core/sdk:3.1"),
        EnvironmentVariables = new Dictionary<string, IBuildEnvironmentVariable>
        {
            ["PROJECT_DIR"] = new BuildEnvironmentVariable { Value = "myproject", Type = BuildEnvironmentVariableType.PLAINTEXT }
        }
    }
});


pushthat avatar Dec 16 '19 10:12 pushthat

@pushthat thank you!!

bruce-igaw avatar Dec 17 '19 00:12 bruce-igaw