codebuild_build.sh script not working with -b option (Mac OS)
Please re-investigate this error, I still see this issue today using the latest version of codebuild_build.sh script, screenshot:
Ref old closed issue: https://github.com/aws/aws-codebuild-docker-images/issues/105
It looks like this path is not correct https://github.com/aws/aws-codebuild-docker-images/blob/413f77ee5474b3219eff86962dddf07e284c9f5b/local_builds/codebuild_build.sh#L122-L125
I manually edit as below to make it works again.
if [ -n "$buildspec" ]
then
docker_command+=" -e \"BUILDSPEC=$buildspec\""
fi
@yeuem1vannam Great! ... If you don't mind please make a PR for that? I'm sure AWS team will appreciate that :D
Hi @ntt2k , we can not reproduce this error. Please share your docker run command if this issue still exists. Thanks!
@awszhen
Here is my command (which is failed with the original code_build.sh)
#!/bin/bash
codebuild_build.sh -i amazon/aws-codebuild-local:latest \
-a /tmp/OutputArtifact \
-s . \
-b buildspec.yml
The failed log:
Build Command:
docker run -it -v /var/run/docker.sock:/var/run/docker.sock -e "IMAGE_NAME=amazon/aws-codebuild-local:latest" -e "ARTIFACTS=/tmp/OutputArtifact" -e "SOURCE=/Users/me/Workspace/my-project/." -e "BUILDSPEC=/Users/me/Workspace/my-project/buildspec.yml" -e "INITIATOR=me" amazon/aws-codebuild-local:latest
Removing agent-resources_build_1 ... done
Removing agent-resources_agent_1 ... done
Removing network agent-resources_default
Removing volume agent-resources_source_volume
Removing volume agent-resources_user_volume
Creating network "agent-resources_default" with the default driver
Creating volume "agent-resources_source_volume" with local driver
Creating volume "agent-resources_user_volume" with local driver
Creating agent-resources_agent_1 ... done
Creating agent-resources_build_1 ... done
Attaching to agent-resources_agent_1, agent-resources_build_1
agent_1 | 2020/01/02 05:02:19 [Customer Config] Couldn't open specified customer config file: open /root/.aws/config: no such file or directory
agent_1 | 2020/01/02 05:02:19 [Customer Config] Error parsing supplied customer config file: invalid argument
agent_1 | [Container] 2020/01/02 05:02:19 Waiting for agent ping
agent_1 | [Container] 2020/01/02 05:02:20 Waiting for DOWNLOAD_SOURCE
agent_1 | [Container] 2020/01/02 05:02:54 Phase is DOWNLOAD_SOURCE
agent_1 | [Container] 2020/01/02 05:02:54 CODEBUILD_SRC_DIR=/codebuild/output/src728485262/src
agent_1 | [Container] 2020/01/02 05:02:54 Phase complete: DOWNLOAD_SOURCE State: FAILED
agent_1 | [Container] 2020/01/02 05:02:54 Phase context status code: YAML_FILE_ERROR Message: stat /Users/me/Workspace/my-project/buildspec.yml: no such file or directory
agent_1 | [Container] 2020/01/02 05:02:54 Runtime error (*clienterr.PhaseContextError: stat /Users/me/Workspace/my-project/buildspec.yml: no such file or directory)
agent-resources_build_1 exited with code 11
Aborting on container exit...
The log said no such file or directory with the path of the host computer instead of inside docker
FYI>
- The file does exist at the host computer
stat /Users/me/Workspace/my-project/buildspec.yml
16777221 4108863 -rw-r--r-- 1 me staff 0 2730 "Dec 18 13:40:49 2019" "Dec 18 13:40:34 2019" "Dec 18 13:40:34 2019" "Dec 18 01:38:07 2019" 4096 8 0 /Users/me/Workspace/my-project/buildspec.yml
- If I omit the
-boption, the command will be success
agent_1 | [Container] 2020/01/02 05:10:11 CODEBUILD_SRC_DIR=/codebuild/output/src722795770/src
agent_1 | [Container] 2020/01/02 05:10:11 YAML location is /codebuild/output/srcDownload/src/buildspec.yml
@yeuem1vannam , In your case, you do not need to provide source directory parameter as it will default to the current working directory:
codebuild_build.sh -i amazon/aws-codebuild-local:latest -a /tmp/OutputArtifact -b buildspec.yml
Or you can specify absolute path of the source directory:
codebuild_build.sh -i amazon/aws-codebuild-local:latest -s /Users/me/Workspace/my-project/ -a /tmp/OutputArtifact -b buildspec.yml
@awszhen
I think the problem is not with -s option to the source directory, but the problem is -b option if buildspec.yml file not at the top level of the source directory. User may want to put "buildspec.yml" file in another folder of the source directory. Please refer to the screenshot, also I think @yeuem1vannam already suggested how to fix it ... asking if he/she can put in the PR ...
Hope these comments make it clear.
Thanks,
@ntt2k , my local build succeeds with buildspec.yml file not at the top level of the source directory. Can you share your docker run command? Thanks.
@awszhen I think there is a misunderstanding here. I didn't run the "docker run" command. But instead using the codebuild_build.sh script with the separate instruction here -->
https://github.com/aws/aws-codebuild-docker-images/blob/master/local_builds/README.md
@ntt2k - please paste the docker run command that you see in the terminal, when you run codebuild_build.sh. Your initial screenshot had that blurred out and @awszhen is asking for that to troubleshoot better.
We'll reopen if we get more info from @ntt2k.
got the same issue.
-
FAIL
codebuild_build -i aws/codebuild/standard:4.0 -a artifacts -s $Source_Folder -c -b deploy/buildspec.ymlcodebuild_build -i aws/codebuild/standard:4.0 -a artifacts -s $Source_Folder -c -b /deploy/buildspec.ymlcodebuild_build -i aws/codebuild/standard:4.0 -a artifacts -s $Source_Folder -c -b ./deploy/buildspec.ymlcodebuild_build -i aws/codebuild/standard:4.0 -a artifacts -s $Source_Folder -c -b $CODEBUILD_SRC_DIR/deploy/buildspec.yml
-
Success
codebuild_build -i aws/codebuild/standard:4.0 -a artifacts -s $Source_Folder -c -b /codebuild/output/srcDownload/src/deploy/buildspec.yml