A developer is configuring an AWS CodeBuild project that runs as a stage in an AWS CodePipeline. During the build execution, a script generates a dynamic version identifier based on the current git commit hash. The developer needs to pass this dynamically generated version identifier directly to a subsequent deployment stage in the pipeline without creating external dependencies. Which configuration in the `buildspec.yml` file will achieve this?
- Define the variable name under the `exported-variables` sequence in the `env` block.Cevap
- BDefine the variable under the `variables` mapping in the `env` block.
- CWrite the version identifier to a temporary text file and declare it under the `files` sequence in the `artifacts` block.
- DStore the version identifier in AWS Systems Manager Parameter Store during the `post_build` phase and retrieve it in the deployment stage.
Cevap
Define the variable name under the `exported-variables` sequence in the `env` block.
Defining the variable name under the `exported-variables` sequence in the `env` block allows CodeBuild to export the value of environment variables that are dynamically set during the build execution. AWS CodePipeline captures these exported variables and makes them available to downstream pipeline actions as variables.
Adım Adım Çözüm
Anahtar Kavram
AWS CodeBuild Exported Variables