Soru

Zorluk: ZorAWS CodeBuild

A company's CI/CD pipeline uses AWS CodeBuild to compile a web application. The build process requires the main application source code from a primary AWS CodeCommit repository, as well as a common stylesheet template from a secondary AWS CodeCommit repository. The developer configures the CodeBuild project with multiple input sources, setting the secondary source identifier to CommonStyles. During the build, the buildspec must copy the stylesheet from the secondary source directory to the main application's public assets folder. How should the developer reference the file path of the secondary source inside the buildspec.yml file to perform this copy operation?

  1. Reference the directory path using the `$CODEBUILD_SRC_DIR_CommonStyles` environment variable.Cevap
  2. B
    Reference the directory path using a relative path from the primary source directory, such as `../CommonStyles`.
  3. C
    Reference the directory path as a subdirectory of the primary working directory, such as `$CODEBUILD_SRC_DIR/CommonStyles`.
  4. D
    Store the repository URL in AWS Systems Manager Parameter Store and resolve it using the `parameters` section of the buildspec.

Cevap

Reference the directory path using the `$CODEBUILD_SRC_DIR_CommonStyles` environment variable.
When configured with multiple input sources, AWS CodeBuild downloads the primary source to the default build directory referenced by `CODEBUILDSRCDIR.Foreachsecondarysource,CodeBuildcreatesaseparatedirectoryandgeneratesadedicatedenvironmentvariablenamedCODEBUILD_SRC_DIR`. For each secondary source, CodeBuild creates a separate directory and generates a dedicated environment variable named ` CODEBUILD_SRC_DIR_source_identifier` where `source_identifier` is the unique identifier specified in the project configuration. Therefore, referencing `$CODEBUILD_SRC_DIR_CommonStyles` provides the correct path to the secondary source repository's files.

Adım Adım Çözüm

1
Identify how AWS CodeBuild handles multiple input sources during a build execution.
The primary source is downloaded to the directory referenced by `$CODEBUILD_SRC_DIR`, while secondary sources are downloaded to separate locations.
Understanding the isolation of source directories prevents incorrect assumptions about directory nesting or relative paths.
2
Determine how CodeBuild exposes the paths of secondary sources to the build environment.
CodeBuild dynamically generates environment variables for each secondary source matching the pattern `$CODEBUILD_SRC_DIR_source_identifier`.
This allows buildspec shell commands to programmatically locate and reference files across different repositories.
3
Select the specific environment variable matching the configured source identifier CommonStyles.
The correct environment variable is `$CODEBUILD_SRC_DIR_CommonStyles`.
This environment variable contains the absolute path to the directory containing the common stylesheet template.

Anahtar Kavram

AWS CodeBuild Multiple Source Inputs
Bu soruyu puanla