0 votes
in AWS by

A developer working on an AWS CodeBuild project wants to override a build command as part of a build run to test a change.

The developer has access to run the builds but does not have access to the code and to edit the CodeBuild project. What process should the Developer use to override the build command?

1 Answer

0 votes
by

Answer - C.

Use the AWS CLI command to specify different parameters that need to be run for the build.

Since the developer can run the build, he can run the build by changing the parameters from the command line.

The same is also mentioned in the AWS Documentation.

Option A is incorrect because A buildspec is a collection of build commands and related settings, in YAML format, that CodeBuild uses to run a build.

You can include a buildspec as part of the source code, or you can define a buildspec when you create a build project.

However, the developer does not have access to the code.

Option B is incorrect because the developer does not have access to the code and to edit the CodeBuild project.

Option D is incorrect because it should be the buildspecOverride property instead of buildspec property.

For more information on running the command via the CLI, please refer to the below Link-

https://docs.aws.amazon.com/codebuild/latest/userguide/run-build.html#run-build-cli

Note:

As per the question, the developer doesn't have access to edit the code build project but only have access to run the build.

So for overriding the existing build we can make use of the BuildspecOverride attribute.

As per AWS,

buildspecOverride.

: Optional string.

A build spec declaration that overrides for this build the one defined in the build project.

If this value is set, it can be either an inline build spec definition or the path to an alternate build spec file relative to the value of the built-in

CODEBUILD_SRC_DIR.

environment variable.

1. Run the start-build command in one of the following ways:  ag  aws codebuild start-build --project-name project-name  Use this if you want to run a build that uses the latest version of the build input artifact and the build project's existing settings.  ag  aws codebuild start-build --generate-cli-skeleton  Use this if you want to run a build with an earlier version of the build input artifact or if you want to override the settings for the build output artifacts, environment variables, build spec, or default build timeout period.

The correct answer for this scenario is C - Run the start build AWS CLI command with buildspecOverride property set to the new buildspec.yml file.

Here's an explanation of why the other options are not correct:

A. Update the buildspec.yml configuration file that is part of the source code and run a new build. This option is not feasible because the developer does not have access to the code. Even if the developer had access to the code, updating the buildspec.yml file would require committing the change to the repository and triggering a new build run, which could take time and may not be desirable if the developer just needs to test a quick change.

B. Update the command in the Build Commands section during the build run in the AWS console. This option is not feasible because the developer does not have access to edit the CodeBuild project. The Build Commands section can only be edited by users with permissions to modify the CodeBuild project.

D. Update the buildspec property in the StartBuild API to override the build command during build run. This option is not entirely correct because the buildspec property in the StartBuild API is used to specify the location of the buildspec.yml file, but it does not allow for overriding the build commands. However, the buildspecOverride property in the StartBuild API can be used to specify a new buildspec.yml file to override the build commands.

Therefore, the best option for the developer is to use the AWS CLI to start a new build run and pass the buildspecOverride property with the location of the new buildspec.yml file containing the updated build commands. This approach will allow the developer to quickly test their changes without having to commit any changes to the source code or have permissions to edit the CodeBuild project.

...