简体   繁体   English

AWS CodeBuild - BuildSpec.yml - 导出变量未解析值

[英]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我正在尝试从 AWS 代码管道的 CodeBuild Stage 导出变量值,但该值未解析

Note: Windows container's PowerShell is executing the commands of buildspec.yml注意:Windows容器的PowerShell正在执行buildspec.yml的命令

Example: I am setting an Input environment variable named Client like below in the AWS CodeBuild project示例:我正在 AWS CodeBuild 项目中设置一个名为 Client 的输入环境变量,如下所示

在此处输入图像描述

and to export the same value I have modified my buildspec.yml like below并导出相同的值我修改了我的 buildspec.yml 如下

version: 0.2版本:0.2

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

but the exported value is expression not the resolved value但导出的值是表达式而不是解析值

在此处输入图像描述

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.提前致谢。

Simply use ${Client} in your buildspec.yml file只需在 buildspec.yml 文件中使用${Client}

You need to change your code as is:您需要按原样更改代码:

env:
  exported-variables:
    - Client

If the name of the variable is Client as defined in the Env.如果变量的名称是 Env 中定义的 Client。 Vars of CodeBuild project thenthe following is enough. Vars of CodeBuild project 那么下面就够了。 You dont need to redefine the same variable in the env->variables section您不需要在env->variables部分重新定义相同的变量

env:
   exported-variables:
   - Client

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AWS Codecommit - Codebuild 将分支名称传递给 buildspec.yml - AWS Codecommit - Codebuild pass branch name to buildspec.yml AWS Copilot 管道失败,为什么 CodeBuild 找不到 buildspec.yml? - AWS Copilot pipeline fails, why cant CodeBuild find buildspec.yml? 您如何编写用于 NodeJS 和 AWS CodeBuild 的 buildspec.yml? - How do you write buildspec.yml for use with NodeJS and AWS CodeBuild? CodeBuild,获取文件夹列表,里面的文件发生了改变buildspec.yml - CodeBuild, get the list of folders that have changed files inside them buildspec.yml 如何使用 buildspec.yml 在 AWS CodePipeline 中从 Dockerfile 构建图像,然后推送到 ECR? - How to build Image from Dockerfile in AWS CodePipeline using buildspec.yml, and then push to ECR? 我们如何通过 Boto3 API 从每个代码构建项目中获取 buildspec.yml 文件的内容 - how can we get contents of a buildspec.yml file from each codebuild project through Boto3 API 如何使用 AWS CodePipeline 为 Laravel 应用程序正确创建 buildspec.yml 文件 - How do I properly create buildspec.yml file for Laravel Application using AWS CodePipeline AWS Codebuild Buildspec Terraform 初始化后端错误 - AWS Codebuild Buildspec Terraform init backend error 如何从 AWS Codebuild buildspec 文件中排除文件夹? - How do I exclude a folder from AWS Codebuild buildspec file? AWS Codebuild 中的多个环境变量与 Terraform - Multiple Environment Variables in AWS Codebuild with Terraform
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM