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

Changes root-directory name of YAML_FILE - path to uppercase automatically, which leads to YAML_FILE_ERROR: no such file or directory

Open AndreasLuckert opened this issue 4 years ago • 5 comments

I run the AWS-CodeBuild locally with the following command in the root-directory of the related project "projectname":

username@hd1pcms0347 MINGW64 ~/Projects/projectname (dev-platform-al)
$ ../aws-codebuild-docker-images/local_builds/codebuild_build.sh -i aws/codebuild/standard:5.0 -a artifacts-output-projectname -s . -b src/build/buildspec.tests.pre-deploy.yml -c /c/Users/username/.aws/config

The output Build Command in the CLI is:

docker run -it -v //var/run/docker.sock:/var/run/docker.sock -e "IMAGE_NAME=aws/codebuild/standard:5.0" -e "ARTIFACTS=//Artifacts-output-projectname" -e "SOURCE=//C/Users/username/Projects/projectname/." -e "BUILDSPEC=//Src/build/buildspec.tests.pre-deploy.yml" -e "AWS_CONFIGURATION=//C/Users/username/.aws" -e "INITIATOR=username" 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  | [Container] 2021/07/05 11:58:43 Waiting for agent ping
agent_1  | [Container] 2021/07/05 11:58:45 Waiting for DOWNLOAD_SOURCE
agent_1  | [Container] 2021/07/05 11:58:46 Phase is DOWNLOAD_SOURCE
agent_1  | [Container] 2021/07/05 11:58:46 CODEBUILD_SRC_DIR=/codebuild/output/src055514407/src
agent_1  | [Container] 2021/07/05 11:58:46 Phase complete: DOWNLOAD_SOURCE State: FAILED
agent_1  | [Container] 2021/07/05 11:58:46 Phase context status code: YAML_FILE_ERROR Message: stat /Src/build/buildspec.tests.pre-deploy.yml: no such file or directory
agent_1  | [Container] 2021/07/05 11:58:46 Runtime error (*clienterr.PhaseContextError: stat /Src/build/buildspec.tests.pre-deploy.yml: no such file or directory)
agent-resources_agent_1 exited with code 0
Aborting on container exit...

Error: /Src/build/buildspec.tests.pre-deploy.yml: no such file or directory

The actual root-directory starts with a lower case like so: src\build\buildspec.tests.pre-deploy.yml

Now this begs the question why the software would change the first letter from lowercase to uppercase?

Next, what does the following state stand for: DOWNLOAD_SOURCE State: FAILED

Is it related to the previous ill-renaming of the root-directory /scr/?

AndreasLuckert avatar Jul 05 '21 13:07 AndreasLuckert

It looks like you're using Windows, which is not fully supported by CodeBuild Local.

Looking at the logs provided, it seems that the relative file paths are being misinterpreted as UNC absolute paths. Specifying a leading ./ may help, as in ./src. In any case, this should be addressed by https://github.com/aws/aws-codebuild-docker-images/issues/328.

josephvusich avatar Jul 08 '21 19:07 josephvusich

Yes, I'm on Windows 10 indeed.

Just tried it with -b ./src/... instead of -b src/.., see the entire command here: ../aws-codebuild-docker-images/local_builds/codebuild_build.sh -i aws/codebuild/standard:5.0 -a artifacts-output-projectname -s . -b ./src/build/buildspec.tests.pre-deploy.yml -c /c/Users/andreas.luckert/.aws/config

The entire output till failure was:

Build Command:

docker run -it -v //var/run/docker.sock:/var/run/docker.sock -e "IMAGE_NAME=aws/codebuild/standard:5.0" -e "ARTIFACTS=//Artifacts-output-projectname" -e "SOURCE=//C/Users/andreas.luckert/Projects/proj/." -e "BUILDSPEC=//C/Users/andreas.luckert/Projects/proj/src/build/buildspec.tests.pre-deploy.yml" -e "AWS_CONFIGURATION=//C/Users/andreas.luckert/.aws" -e "INITIATOR=andreas.luckert" 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  | [Container] 2021/07/09 07:22:04 Waiting for agent ping
agent_1  | [Container] 2021/07/09 07:22:06 Waiting for DOWNLOAD_SOURCE
agent_1  | [Container] 2021/07/09 07:22:07 Phase is DOWNLOAD_SOURCE
agent_1  | [Container] 2021/07/09 07:22:07 CODEBUILD_SRC_DIR=/codebuild/output/src243879863/src
agent_1  | [Container] 2021/07/09 07:22:07 Phase complete: DOWNLOAD_SOURCE State: FAILED
agent_1  | [Container] 2021/07/09 07:22:07 Phase context status code: YAML_FILE_ERROR Message: stat 

/C/Users/andreas.luckert/Projects/proj/src/build/buildspec.tests.pre-deploy.yml: no such file or directory
agent_1  | [Container] 2021/07/09 07:22:07 Runtime error (*clienterr.PhaseContextError: stat /C/Users/andreas.luckert/Projects/proj/src/build/buildspec.tests.pre-deploy.yml: no such file or directory)

agent-resources_build_1 exited with code 11
Aborting on container exit...

This time, the program prepended the full path, but again made the first letter capital (/C/.. instead of /c/...).

AndreasLuckert avatar Jul 09 '21 07:07 AndreasLuckert

/C/Users looks like MSYS path translation from the shell/terminal. You may be able to get around this by using absolute paths starting with C:.

josephvusich avatar Jul 09 '21 21:07 josephvusich

Following your advice, I replaced -b ./src/build/buildspec.tests.pre-deploy.yml with "C:\Users\andreas.luckert\Projects\proj\src\build\buildspec.tests.pre-deploy.yml"

to get the final command: ../aws-codebuild-docker-images/local_builds/codebuild_build.sh -i aws/codebuild/standard:5.0 -a artifacts-output-projectname -s . -b "C:\Users\andreas.luckert\Projects\proj\src\build\buildspec.tests.pre-deploy.yml" -c /c/Users/andreas.luckert/.aws/config

The output was yet again:

Build Command:

docker run -it -v //var/run/docker.sock:/var/run/docker.sock -e "IMAGE_NAME=aws/codebuild/standard:5.0" -e "ARTIFACTS=//Artifacts-output-projectname" -e "SOURCE=//C/Users/andreas.luckert/Projects/proj/." -e "BUILDSPEC=//C/Users/andreas.luckert/Projects/proj/src/build/buildspec.tests.pre-deploy.yml" -e "AWS_CONFIGURATION=//C/Users/andreas.luckert/.aws" -e "INITIATOR=andreas.luckert" 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  | [Container] 2021/07/12 07:54:48 Waiting for agent ping
agent_1  | [Container] 2021/07/12 07:54:50 Waiting for DOWNLOAD_SOURCE
agent_1  | [Container] 2021/07/12 07:54:50 Phase is DOWNLOAD_SOURCE
agent_1  | [Container] 2021/07/12 07:54:50 CODEBUILD_SRC_DIR=/codebuild/output/src154752762/src
agent_1  | [Container] 2021/07/12 07:54:50 Phase complete: DOWNLOAD_SOURCE State: FAILED
agent_1  | [Container] 2021/07/12 07:54:50 Phase context status code: YAML_FILE_ERROR Message: stat /C/Users/andreas.luckert/Projects/proj/src/build/buildspec.tests.pre-deploy.yml: no such file or directory
agent_1  | [Container] 2021/07/12 07:54:50 Runtime error (*clienterr.PhaseContextError: stat /C/Users/andreas.luckert/Projects/proj/src/build/buildspec.tests.pre-deploy.yml: no such file or directory)
agent-resources_build_1 exited with code 11
Aborting on container exit...

Then, for the sake of completeness, I replaced also -c /c/Users/andreas.luckert/.aws/config with "C:\Users\andreas.luckert\.aws\config"

to obtain the final command: ../aws-codebuild-docker-images/local_builds/codebuild_build.sh -i aws/codebuild/standard:5.0 -a artifacts-output-projectname -s . -b "C:\Users\andreas.luckert\Projects\proj\src\build\buildspec.tests.pre-deploy.yml" -c "C:\Users\andreas.luckert\.aws\config"

Regarding the output, it did not have a notable effect:

Build Command:

docker run -it -v //var/run/docker.sock:/var/run/docker.sock -e "IMAGE_NAME=aws/codebuild/standard:5.0" -e "ARTIFACTS=//Artifacts-output-projectname" -e "SOURCE=//C/Users/andreas.luckert/Projects/proj/." -e "BUILDSPEC=//C/Users/andreas.luckert/Projects/proj/src/build/buildspec.tests.pre-deploy.yml" -e "AWS_CONFIGURATION=//C/Users/andreas.luckert/.aws" -e "INITIATOR=andreas.luckert" 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  | [Container] 2021/07/12 07:55:49 Waiting for agent ping
agent_1  | [Container] 2021/07/12 07:55:51 Waiting for DOWNLOAD_SOURCE
agent_1  | [Container] 2021/07/12 07:55:51 Phase is DOWNLOAD_SOURCE
agent_1  | [Container] 2021/07/12 07:55:51 CODEBUILD_SRC_DIR=/codebuild/output/src572911371/src
agent_1  | [Container] 2021/07/12 07:55:51 Phase complete: DOWNLOAD_SOURCE State: FAILED
agent_1  | [Container] 2021/07/12 07:55:51 Phase context status code: YAML_FILE_ERROR Message: stat /C/Users/andreas.luckert/Projects/proj/src/build/buildspec.tests.pre-deploy.yml: no such file or directory
agent_1  | [Container] 2021/07/12 07:55:51 Runtime error (*clienterr.PhaseContextError: stat /C/Users/andreas.luckert/Projects/proj/src/build/buildspec.tests.pre-deploy.yml: no such file or directory)   
agent-resources_build_1 exited with code 11
Aborting on container exit...

NOTE on double-quotes around the paths containing the Windows-separator "":

This is mandatory since without quotes e.g. the buildspec.yml - file would be interpreted like so: /CUsersandreas.luckertProjectsprojsrcbuildbuildspec.tests.pre-deploy.yml

AndreasLuckert avatar Jul 12 '21 08:07 AndreasLuckert

Not positive, but maybe this issue is addressed by pending PR #619 or my version

See comment https://github.com/aws/aws-codebuild-docker-images/issues/328#issuecomment-1498212227

devt avatar Apr 06 '23 12:04 devt