copilot-cli: Pipeline fails in CodeBuild POST_BUILD with `COMMAND_EXECUTION_ERROR Message: Error while executing command: for env in $pl_envs;`
Hello, I’m using Copilot in windows for a dotnet project. I have a pipeline that that fails in CodeBuild on the POST_BUILD phase with the following error:
Build logs shows this error:
[Container] 2022/05/11 04:20:06 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: for env in $pl_envs; do tag=$(sed 's/:/-/g' <<<"${CODEBUILD_BUILD_ID##*:}-${env}" | rev | cut -c 1-128 | rev) for svc in $svcs; do ./copilot-linux svc package -n $svc -e $env --output-dir './infrastructure' --tag $tag --upload-assets; if [ $? -ne 0 ]; then echo "Cloudformation stack and config files were not generated. Please check build logs to see if there was a manifest validation error." 1>&2; exit 1; fi done; for job in $jobs; do ./copilot-linux job package -n $job -e $env --output-dir './infrastructure' --tag $tag --upload-assets; if [ $? -ne 0 ]; then echo "Cloudformation stack and config files were not generated. Please check build logs to see if there was a manifest validation error." 1>&2; exit 1; fi done; done; . Reason: exit status 1
It refers to this line in buildspec.yml:
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17 (5 by maintainers)
Commits related to this issue
- chore(pipelines): remove here string from buildspec (#4102) Fixes second issue in #3553. Here strings (`<<<`) don't work with `sh`. This change makes the pipeline buildspec a bit more universal. By... — committed to aws/copilot-cli by huanjani 2 years ago
- chore(pipelines): remove here string from buildspec (#4102) Fixes second issue in #3553. Here strings (`<<<`) don't work with `sh`. This change makes the pipeline buildspec a bit more universal. By... — committed to KollaAdithya/copilot-cli by huanjani 2 years ago
I am experiencing a similar error when I use the Ubuntu
aws/codebuild/standard:6.0
image in CodeBuild. Here is an extract from my logs:I could not 100% confirm this but my hypothesis is that the commands are running in
sh
instead ofbash
and thus the <<< in the second line does not parse.Since the generated buildspec is already using Ruby in other parts of the build I replaced it with a more portable version and it works correctly for me now.
No rush! Hope you’re feeling better!
Thanks! Can you also paste here the manifests for the workloads (services/jobs) that you’re attempting to deploy with this pipeline?
Hi, @ryancody! Would you mind copy-pasting your manifest here? Thanks!