简体   繁体   English

AWS CodeBuild Batch 配置未传递环境变量

[英]AWS CodeBuild Batch configuration not passing environment variables

I am trying to use the CodeBuild Batch configuration feature to trigger 2 different build from the same repository.我正在尝试使用 CodeBuild Batch 配置功能从同一存储库触发 2 个不同的构建。 For the 2 build commands, only some parameters differ which I am trying to manage through environment variables, below is the buildSpec file.对于 2 个构建命令,只有一些参数不同,我试图通过环境变量进行管理,下面是buildSpec文件。

version: 0.2
batch:
  fast-fail: true
  build-list:
    - identifier: build1
      buildspec: buildspec1.yml
      env:
        variables:
          BUILD_ID:  build1ID
          privileged-mode: true
          PROJECT: Projectvalue
      ignore-failure: false
    - identifier: evaluator-build
      buildspec: buildspecs2.yml
      env:
        variables:
          BUILD_ID: build2ID
          PROJECT: ProjectValueTwo
      ignore-failure: false

phases:
  build:
    commands:
    - echo Build started on `date`
    - sbt clean
    - sbt 'project $PROJECT' 'compile'

Here Project is one of the variables I am trying to pass between the 2 builds, but the actual value is not being passed.这里Project是我试图在 2 个构建之间传递的变量之一,但实际值没有被传递。 I tried echoing the value for it but comes out as blank.我尝试回显它的值,但显示为空白。

What could be wrong here?这里有什么问题? Also, is the batch config feature use correct here?另外,批处理配置功能在这里使用正确吗?

I had this problem too.我也有这个问题。 The batch configuration block is only used in batch builds, not in single builds. batch配置块仅用于批处理构建,而不是单个构建。

You can run batch builds either using 'build with overrides' or configured via a webhook then selecting batch rather than single .您可以使用“带有覆盖的构建”或通过 webhook 配置运行批处理构建,然后选择batch而不是single Once I switched to this then it worked as expected for me with environment variables being inserted.一旦我切换到这个,它就会像我预期的那样工作,并插入环境变量。

Please note you need to add a 'batch configuration' for your CodeBuild project before this will work: https://docs.aws.amazon.com/codebuild/latest/userguide/create-project-console.html#create-project-console-batch-config请注意,您需要为您的 CodeBuild 项目添加“批量配置”,然后才能使用: https://docs.aws.amazon.com/codebuild/latest/userguide/create-project-console.html#create-project-控制台批处理配置

If you don't have a batch configuration then a webhook-triggered build seems to silently fail but you do get an error if you try to run a batch build from 'build with overrides'.如果您没有批处理配置,那么由 webhook 触发的构建似乎会静默失败,但如果您尝试从“使用覆盖的构建”运行批处理构建,则会收到错误消息。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM