aws-codebuild-docker-images icon indicating copy to clipboard operation
aws-codebuild-docker-images copied to clipboard

Local build not working on Mac with -b option

Open sshvans opened this issue 8 years ago • 4 comments

I am running local build .sh file on Mac to run cobebuild agent locally, but seeing following error.

Command: ./codebuild_build.sh -i aws/codebuild/python:3.6.5 -a /Users/sshvans/Documents/artifacts -s /Users/sshvans/Documents/test -b /Users/sshvans/Documents/test/assets/buildspec.yml

Output: `Build Command:

docker run -it -v /var/run/docker.sock:/var/run/docker.sock -e "IMAGE_NAME=aws/codebuild/python:3.6.5" -e "ARTIFACTS=/Users/sshvans/Documents/artifacts" -e "SOURCE=/Users/sshvans/Documents/test" -e "BUILDSPEC=/Users/sshvans/Documents/test/assets/buildspec.yml" amazon/aws-codebuild-local:latest

Removing agentresources_build_1 ... done Removing agentresources_agent_1 ... done Removing network agentresources_default Removing volume agentresources_user_volume Removing volume agentresources_source_volume Creating network "agentresources_default" with the default driver Creating volume "agentresources_user_volume" with local driver Creating volume "agentresources_source_volume" with local driver Creating agentresources_agent_1 ... Creating agentresources_agent_1 ... done Creating agentresources_build_1 ... Creating agentresources_build_1 ... done Attaching to agentresources_agent_1, agentresources_build_1 agent_1 | [Container] 2018/08/16 23:23:09 Waiting for agent ping agent_1 | [Container] 2018/08/16 23:23:09 Waiting for DOWNLOAD_SOURCE agent_1 | [Container] 2018/08/16 23:23:10 Phase is DOWNLOAD_SOURCE agent_1 | [Container] 2018/08/16 23:23:10 CODEBUILD_SRC_DIR=/codebuild/output/src954031307/src agent_1 | [Container] 2018/08/16 23:23:10 Phase complete: DOWNLOAD_SOURCE Success: false agent_1 | [Container] 2018/08/16 23:23:10 Phase context status code: YAML_FILE_ERROR Message: stat /Users/sshvans/Documents/test/assets/buildspec.yml: no such file or directory agent_1 | [Container] 2018/08/16 23:23:10 Runtime error (*os.PathError: stat /Users/sshvans/Documents/test/assets/buildspec.yml: no such file or directory)`

At first it seems like the buildspec.yml file doesn't exist at the given location, but I have confirmed and this file do exist. When I remove the the -b option, the command runs successfully. See below.

Command: ./codebuild_build.sh -i aws/codebuild/python:3.6.5 -a /Users/sshvans/Documents/artifacts -s /Users/sshvans/Documents/test

Output: ` Build Command:

docker run -it -v /var/run/docker.sock:/var/run/docker.sock -e "IMAGE_NAME=aws/codebuild/python:3.6.5" -e "ARTIFACTS=/Users/sshvans/Documents/Work/artifacts" -e "SOURCE=/Users/sshvans/Documents/test" amazon/aws-codebuild-local:latest

Removing agentresources_build_1 ... done Removing agentresources_agent_1 ... done Removing network agentresources_default Removing volume agentresources_user_volume Removing volume agentresources_source_volume Creating network "agentresources_default" with the default driver Creating volume "agentresources_user_volume" with local driver Creating volume "agentresources_source_volume" with local driver Creating agentresources_agent_1 ... Creating agentresources_agent_1 ... done Creating agentresources_build_1 ... Creating agentresources_build_1 ... done Attaching to agentresources_agent_1, agentresources_build_1 agent_1 | [Container] 2018/08/16 23:30:56 Waiting for agent ping agent_1 | [Container] 2018/08/16 23:30:56 Waiting for DOWNLOAD_SOURCE agent_1 | [Container] 2018/08/16 23:30:57 Phase is DOWNLOAD_SOURCE agent_1 | [Container] 2018/08/16 23:30:57 CODEBUILD_SRC_DIR=/codebuild/output/src885802506/src agent_1 | [Container] 2018/08/16 23:30:57 YAML location is /codebuild/output/src885802506/src/buildspec.yml agent_1 | [Container] 2018/08/16 23:30:57 Processing environment variables agent_1 | [Container] 2018/08/16 23:30:57 Moving to directory /codebuild/output/src885802506/src agent_1 | [Container] 2018/08/16 23:30:57 Registering with agent agent_1 | [Container] 2018/08/16 23:30:57 Phases found in YAML: 3 agent_1 | [Container] 2018/08/16 23:30:57 INSTALL: 4 commands agent_1 | [Container] 2018/08/16 23:30:57 PRE_BUILD: 14 commands agent_1 | [Container] 2018/08/16 23:30:57 BUILD: 4 commands agent_1 | [Container] 2018/08/16 23:30:57 Phase complete: DOWNLOAD_SOURCE Success: true agent_1 | [Container] 2018/08/16 23:30:57 Phase context status code: Message: agent_1 | [Container] 2018/08/16 23:30:57 Entering phase INSTALL agent_1 | [Container] 2018/08/16 23:30:57 Running command echo Entered the install phase... agent_1 | Entered the install phase... agent_1 | agent_1 | [Container] 2018/08/16 23:30:57 Running command apt-get update -y agent_1 | Get:1 http://ppa.launchpad.net trusty InRelease [15.4 kB] agent_1 | Ign http://archive.ubuntu.com trusty InRelease agent_1 | Get:2 http://archive.ubuntu.com trusty-updates InRelease [65.9 kB] agent_1 | Get:3 http://archive.ubuntu.com trusty-security InRelease [65.9 kB] agent_1 | Get:4 http://archive.ubuntu.com trusty Release.gpg [933 B] agent_1 | Get:5 http://archive.ubuntu.com trusty Release [58.5 kB] agent_1 | Get:6 http://ppa.launchpad.net trusty/main amd64 Packages [3482 B] agent_1 | Get:7 http://archive.ubuntu.com trusty-updates/main Sources [519 kB] . . `

sshvans avatar Aug 16 '18 23:08 sshvans

Hi,

The -b option takes relative path as input. In this case, since your buildspec is in assets/buildspec.yml, you can specify -b assets/buildspec.yml to make it work.

If you don't specify anything, the local agent will look for buildspec.yml in root dir of your source.

Thanks,

Kaixiang-AWS avatar Aug 17 '18 17:08 Kaixiang-AWS

Please re-investigate this error, I still see this issue today using the latest version of codebuild_build.sh script, screenshot:

Screen Shot 2019-12-03 at 3 53 41 PM

Screen Shot 2019-12-03 at 3 47 42 PM

ntt2k avatar Dec 03 '19 22:12 ntt2k

@ntt2k Did you find any solution for this already? I'm experiencing same issues here.. have you tried putting the buildspec.yml temporarily in the root? Does it work then?

tdhulster avatar Jan 10 '20 10:01 tdhulster

@ntt2k if I run codebuild local with "-c default" it gives the same error. are you trying to use the default profile there? if I run it with "-c -p default" it works

rl-michaelbrandeis avatar Jun 27 '20 21:06 rl-michaelbrandeis