aws codepipeline - amazon-web-services

I am new to AWS CodePipeline. When trying to deploy an application using docker images and ECS services, I am getting the following error using my buildspec.yml file:
[Container] 2018/08/14 06:20:36 Phase context status code: Message:
[Container] 2018/08/14 06:20:36 Entering phase INSTALL
[Container] 2018/08/14 06:20:36 Phase complete: INSTALL Success: true
[Container] 2018/08/14 06:20:36 Phase context status code: Message:
[Container] 2018/08/14 06:20:36 Entering phase PRE_BUILD
[Container] 2018/08/14 06:20:36 Running command echo Logging in to Amazon ECR... Logging in to Amazon ECR...
[Container] 2018/08/14 06:20:36 Running command aws --version aws-cli/1.15.41 Python/2.7.6 Linux/4.14.47-56.37.amzn1.x86_64 botocore/1.10.41
[Container] 2018/08/14 06:20:39 Running command $(aws ecr get-login --no-include-email --region us-east-xxx) WARNING! Using --password via the CLI is insecure. Use --password-stdin. Login Succeeded
[Container] 2018/08/14 06:20:40 Running command REPOSITORY_URI= xxxx.xxxx.ecr.us-east-xxx.amazonaws.com/python /codebuild/output/tmp/script.sh: 4: /codebuild/output/tmp/script.sh: xxxx.xxxx.ecr.us-east-xxx.amazonaws.com/python: not found
[Container] 2018/08/14 06:20:40 Command did not exit successfully REPOSITORY_URI= xxxx.xxxx.ecr.us-east-xxx.amazonaws.com/python exit status 127
[Container] 2018/08/14 06:20:40 Phase complete: PRE_BUILD Success: false
[Container] 2018/08/14 06:20:40 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: REPOSITORY_URI= xxxx.xxxx.ecr.us-east-xxx.amazonaws.com/python. Reason: exit status 127
Any assistance is appreciated. If it helps, I can attach my buildspec.yml and taskdefinition.json files. Is there a recommended way to do that?

It seems you have a space between = and xxxx.xxxx.ecr.us-east-xxx.amazonaws.com/python.
This means you're evaluating xxxx.xxxx.ecr.us-east-xxx.amazonaws.com/python as a command, and since this URI is not a valid command, it exits with status code 127.
Simply deleting the space should help.

Related

Image not sent to ecr from codebuild while buildspec has no error

yaml executed successfully in AWS code build but image not send to aws ecr.
buildspec.yml file output is given below
`[Container] 2020/10/26 09:50:07 Phase complete: PRE_BUILD State: SUCCEEDED
[Container] 2020/10/26 09:50:07 Phase context status code: Message:
[Container] 2020/10/26 09:50:07 Entering phase BUILD
[Container] 2020/10/26 09:50:07 Phase complete: BUILD State: SUCCEEDED
[Container] 2020/10/26 09:50:07 Phase context status code: Message:
[Container] 2020/10/26 09:50:07 Entering phase POST_BUILD
[Container] 2020/10/26 09:50:07 Phase complete: POST_BUILD State: SUCCEEDED
[Container] 2020/10/26 09:50:07 Phase context status code: Message: `
Every phase is executed successfully with SUCCEEDED message.
Below is the buildspec.yml file code snippet
build:
commands:
- echo Build started on `date`
- echo Building the Docker image...
- docker build -t $REPOSITORY_URI:latest .
- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
post_build:
commands:
- echo Build completed on `date`
- echo Pushing the Docker images...
- docker push $REPOSITORY_URI:latest
- docker push $REPOSITORY_URI:$IMAGE_TAG
- echo Writing image definitions file...
- printf '[{"name":"ui","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json
- cat imagedefinitions.json
No command is being run due to bad indentation. Please rectify the indentation using the buildspec reference as guide:
https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html
Also I do not see a docker login before the push:
- aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
A buildspce sample for Docker is here:
https://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html#sample-docker-files

AWS ECS CodePipeline build error REPOSITORY_URI

we wanna try CodePipeline with a image that we already have on ECR.
So we follow the steps on the documentation.
We have buildspec.yml like this:
phases:
install:
runtime-versions:
nodejs: 10
pre_build:
commands:
- echo Logging in to Amazon ECR...
- aws --version
- $(aws ecr get-login --no-include-email --region us-east-1)
- REPOSITORY_URI=OUR_URL_FROM_ECR
- COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
- IMAGE_TAG=${COMMIT_HASH:=latest}
- echo $REPOSITORY_URI
- echo $COMMIT_HASH
- echo $IMAGE_TAG
build:
commands:
- echo Build started on `date`
- echo Building the Docker image...
- docker build -t $REPOSITORY_URI:latest .
- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
post_build:
commands:
- echo Build completed on `date`
- echo Pushing the Docker images...
- docker push $REPOSITORY_URI:latest
- docker push $REPOSITORY_URI:$IMAGE_TAG
- echo Writing image definitions file...
- printf '[{"name":"Petr","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json
artifacts:
files: imagedefinitions.json
We created a new pipeline flow, but when we push some changes we get this log:
[Container] 2019/11/07 23:30:49 Waiting for agent ping
[Container] 2019/11/07 23:30:51 Waiting for DOWNLOAD_SOURCE
[Container] 2019/11/07 23:30:52 Phase is DOWNLOAD_SOURCE
[Container] 2019/11/07 23:30:52 CODEBUILD_SRC_DIR=/codebuild/output/src386464501/src
[Container] 2019/11/07 23:30:52 YAML location is /codebuild/output/src386464501/src/buildspec.yml
[Container] 2019/11/07 23:30:52 No commands found for phase name: INSTALL
[Container] 2019/11/07 23:30:52 Processing environment variables
[Container] 2019/11/07 23:30:52 Moving to directory /codebuild/output/src386464501/src
[Container] 2019/11/07 23:30:52 Registering with agent
[Container] 2019/11/07 23:30:52 Phases found in YAML: 4
[Container] 2019/11/07 23:30:52 POST_BUILD: 6 commands
[Container] 2019/11/07 23:30:52 INSTALL: 0 commands
[Container] 2019/11/07 23:30:52 PRE_BUILD: 9 commands
[Container] 2019/11/07 23:30:52 BUILD: 4 commands
[Container] 2019/11/07 23:30:52 Phase complete: DOWNLOAD_SOURCE State: SUCCEEDED
[Container] 2019/11/07 23:30:52 Phase context status code: Message:
[Container] 2019/11/07 23:30:52 Entering phase INSTALL
[Container] 2019/11/07 23:30:52 Running command echo "Installing Node.js version 10 ..."
Installing Node.js version 10 ...
[Container] 2019/11/07 23:30:52 Running command n 10.16.3
installed : v10.16.3 (with npm 6.9.0)
[Container] 2019/11/07 23:31:02 Phase complete: INSTALL State: SUCCEEDED
[Container] 2019/11/07 23:31:02 Phase context status code: Message:
[Container] 2019/11/07 23:31:02 Entering phase PRE_BUILD
[Container] 2019/11/07 23:31:02 Running command echo Logging in to Amazon ECR...
Logging in to Amazon ECR...
[Container] 2019/11/07 23:31:02 Running command aws --version
aws-cli/1.16.242 Python/3.6.8 Linux/4.14.143-91.122.amzn1.x86_64 exec-env/AWS_ECS_EC2 botocore/1.12.232
[Container] 2019/11/07 23:31:07 Running command $(aws ecr get-login --no-include-email --region us-east-1)
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
[Container] 2019/11/07 23:31:10 Running command REPOSITORY_URI=***********
[Container] 2019/11/07 23:31:10 Running command COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
[Container] 2019/11/07 23:31:10 Running command IMAGE_TAG=${COMMIT_HASH:=latest}
[Container] 2019/11/07 23:31:10 Running command echo $REPOSITORY_URI
***********
[Container] 2019/11/07 23:31:10 Running command echo $COMMIT_HASH
88f8cfc
[Container] 2019/11/07 23:31:10 Running command echo $IMAGE_TAG
88f8cfc
[Container] 2019/11/07 23:31:10 Phase complete: PRE_BUILD State: SUCCEEDED
[Container] 2019/11/07 23:31:10 Phase context status code: Message:
[Container] 2019/11/07 23:31:10 Entering phase BUILD
[Container] 2019/11/07 23:31:10 Running command echo Build started on `date`
Build started on Thu Nov 7 23:31:10 UTC 2019
[Container] 2019/11/07 23:31:10 Running command echo Building the Docker image...
Building the Docker image...
[Container] 2019/11/07 23:31:10 Running command docker build -t $REPOSITORY_URI:latest .
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[Container] 2019/11/07 23:31:10 Command did not exit successfully docker build -t $REPOSITORY_URI:latest . exit status 1
[Container] 2019/11/07 23:31:10 Phase complete: BUILD State: FAILED
[Container] 2019/11/07 23:31:10 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: docker build -t $REPOSITORY_URI:latest .. Reason: exit status 1
[Container] 2019/11/07 23:31:10 Entering phase POST_BUILD
[Container] 2019/11/07 23:31:10 Running command echo Build completed on `date`
Build completed on Thu Nov 7 23:31:10 UTC 2019
[Container] 2019/11/07 23:31:10 Running command echo Pushing the Docker images...
Pushing the Docker images...
[Container] 2019/11/07 23:31:10 Running command docker push $REPOSITORY_URI:latest
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[Container] 2019/11/07 23:31:10 Command did not exit successfully docker push $REPOSITORY_URI:latest exit status 1
[Container] 2019/11/07 23:31:10 Phase complete: POST_BUILD State: FAILED
[Container] 2019/11/07 23:31:10 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: docker push $REPOSITORY_URI:latest. Reason: exit status 1
[Container] 2019/11/07 23:31:10 Expanding base directory path: .
[Container] 2019/11/07 23:31:10 Assembling file list
[Container] 2019/11/07 23:31:10 Expanding .
[Container] 2019/11/07 23:31:10 Expanding file paths for base directory .
[Container] 2019/11/07 23:31:10 Assembling file list
[Container] 2019/11/07 23:31:10 Expanding imagedefinitions.json
[Container] 2019/11/07 23:31:10 Skipping invalid file path imagedefinitions.json
[Container] 2019/11/07 23:31:10 Phase complete: UPLOAD_ARTIFACTS State: FAILED
[Container] 2019/11/07 23:31:10 Phase context status code: CLIENT_ERROR Message: no matching artifact paths found
We wanna know if we are missing something, we follow some steps from here:
https://aws.amazon.com/es/blogs/devops/build-a-continuous-delivery-pipeline-for-your-container-images-with-amazon-ecr-as-source/
Any advice?
I ran into similar error. The fix is, this build project needs to build a Docker image therefore set Privilege Mode to true.
Privileged mode grants a build project's Docker container access.
There will be two possibilities:-
one is that you didn't add ecr and ecs in your roles which you created for ec2 instance or if you are using elastic beanstalk. first verify that
otherwise look into this second possibility:-
Use following commands in your phases:-
phases:
install:
commands:
- nohup /usr/local/bin/dockerd --host=unix:///var/run/docker.sock --host=tcp://127.0.0.1:2375 --storage-driver=overlay2&
- timeout 15 sh -c "until docker info; do echo .; sleep 1; done"
for more details use this link
https://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker-custom-image.html#sample-docker-custom-image-files
https://docs.aws.amazon.com/codebuild/latest/userguide/troubleshooting.html#troubleshooting-cannot-connect-to-docker-daemon
For error
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is
the docker daemon running?
I found this helpful:
https://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html
Specifically point 5.d.
Follow the steps in Run CodeBuild directly to create a build project, run the build, and view build information.
If you use the console to create your project:
a. For Operating system, choose Ubuntu.
b. For Runtime, choose Standard.
c. For Image, choose aws/codebuild/standard:4.0.
d. Because you use this build project to build a Docker image, select Privileged.
I have had the same problem as you and the way I fixed it was by following: try going to CodeBuild and then to its IAM Role. AmazonEC2ContainerRegistryFullAccess role and now click on 'Edit' for that code build and select 'Environment' and click on Allow AWS CodeBuild to modify this service role so it can be used with this building project. Now try again.
Cheers

Code build is failed with Error while executing command: npm install. Reason: exit status 127

I created a code pipeline with very simple code and connected to codecommit. tried to build it but it is failing at codebuild step stating error executing npm install. Am I missing something? Sorry I was new to this codebuild/ codepipeline.
Below is the log for codebuild failure:
[Container] 2019/02/15 11:47:39 Waiting for agent ping
[Container] 2019/02/15 11:47:40 Waiting for DOWNLOAD_SOURCE
[Container] 2019/02/15 11:47:40 Phase is DOWNLOAD_SOURCE
[Container] 2019/02/15 11:47:40 CODEBUILD_SRC_DIR=/codebuild/output/src501317273/src
[Container] 2019/02/15 11:47:40 YAML location is /codebuild/output/src501317273/src/buildspec.yml
[Container] 2019/02/15 11:47:40 Processing environment variables
[Container] 2019/02/15 11:47:40 Moving to directory /codebuild/output/src501317273/src
[Container] 2019/02/15 11:47:40 Registering with agent
[Container] 2019/02/15 11:47:40 Phases found in YAML: 1
[Container] 2019/02/15 11:47:40 BUILD: 2 commands
[Container] 2019/02/15 11:47:40 Phase complete: DOWNLOAD_SOURCE Success: true
[Container] 2019/02/15 11:47:40 Phase context status code: Message:
[Container] 2019/02/15 11:47:40 Entering phase INSTALL
[Container] 2019/02/15 11:47:40 Phase complete: INSTALL Success: true
[Container] 2019/02/15 11:47:40 Phase context status code: Message:
[Container] 2019/02/15 11:47:40 Entering phase PRE_BUILD
[Container] 2019/02/15 11:47:40 Phase complete: PRE_BUILD Success: true
[Container] 2019/02/15 11:47:40 Phase context status code: Message:
[Container] 2019/02/15 11:47:41 Entering phase BUILD
[Container] 2019/02/15 11:47:41 Running command npm install
sh: 1: npm: not found
[Container] 2019/02/15 11:47:41 Command did not exit successfully npm install exit status 127
[Container] 2019/02/15 11:47:41 Phase complete: BUILD Success: false
[Container] 2019/02/15 11:47:41 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: npm install. Reason: exit status 127
[Container] 2019/02/15 11:47:41 Entering phase POST_BUILD
[Container] 2019/02/15 11:47:41 Phase complete: POST_BUILD Success: true
[Container] 2019/02/15 11:47:41 Phase context status code: Message:
[Container] 2019/02/15 11:47:41 Expanding base directory path: .
[Container] 2019/02/15 11:47:41 Assembling file list
[Container] 2019/02/15 11:47:41 Expanding .
[Container] 2019/02/15 11:47:41 Expanding artifact file paths for base directory .
[Container] 2019/02/15 11:47:41 Assembling file list
[Container] 2019/02/15 11:47:41 Expanding post-saml.yaml
[Container] 2019/02/15 11:47:41 Skipping invalid artifact path post-saml.yaml
[Container] 2019/02/15 11:47:41 Expanding beta.json
[Container] 2019/02/15 11:47:41 Found 1 file(s)
[Container] 2019/02/15 11:47:41 Phase complete: UPLOAD_ARTIFACTS Success: true
[Container] 2019/02/15 11:47:41 Phase context status code: Message:
My buildspec.yml file looks like this:
version: 0.0
environment_variables:
plaintext:
"INPUT_FILE": "serverless.yml"
"S3_BUCKET": ""
containers:
LambdaFunctions:
phases:
during_build:
commands:
- npm install
- aws cloudformation package --template $INPUT_FILE --s3-bucket $S3_BUCKET --output-template post-saml.yaml
artifacts:
files:
- post-saml.yaml
- beta.json
The error message is a few lines down your logs : sh: 1: npm: not found.
This means the npm command is not available in the build environment. Did you correctly select a nodejs build ?
When you create a build environment, you have to specify the operating system and the runtime. It is very unlikely here that you did not specifcy nodejs as runtime.
See step by step guide here : https://docs.aws.amazon.com/codebuild/latest/userguide/getting-started.html#getting-started-create-build-project
See documentation here : https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html
And see a screenshot from my console here :
Just posting this here in case someone else comes across it in the future. OP buildspec.yaml should work if updated to the following
BuildSpec Reference
Changelog:
updated buildspec to version .2
added a nodejs dependency to the install phase
version: 0.2
env:
variables:
INPUT_FILE: "serverless.yml"
S3_BUCKET: ""
phases:
install:
runtime-versions:
nodejs: 10
commands:
- npm install
build:
commands:
- aws cloudformation package --template $INPUT_FILE --s3-bucket $S3_BUCKET --output-template post-saml.yaml
artifacts:
files:
- post-saml.yaml
- beta.json
I had the same issue. To see the actual issue please check the build logs carefully. It's not the error shown in red, but few line above this.
(1) Something to do with permission od the code build service role.
I assigned the administration access temporarily and it worked but failed due to different reason.
To check it, try to execute the simple cloud-formation command like ‘aws cloudformation list-stacks’ only ( try it with inline command option or leave this command only and see it works.
(2) The issue with mine was a samtemplate file (I was trying with C#), in your case serverless.yml. It was creating a build file in one location, but my samtemplate referring to a different location. if possible, try the same command from you AWS CLI in you local machine
There may be a chance you have selected a wrong Os/image etc.. Check
https://docs.aws.amazon.com/codebuild/latest/userguide/getting-started-create-build-project-console.html
Adding as it may help someone. I received an error that read:
/codebuild/output/tmp/script.sh: 4: ‘npm: not found
It turned out this was due to the quotation marks.

AWS CodeBuild - cd: can't cd to /codebuild/output/src... error and artifacts path not found

===============
I'm new to AWS CodeBuild. We are trying it for the first time. I set up my Buildspec.yml file and when I run it I get errors indicating that it cd: can't cd to /codebuild/output/src.... throughout the build run, however it progresses to the next step each time disregarding the errors. However, when it gets to the artifacts step it can't find the artifacts path. I've tried many iterations of the artifacts: files: statements with no luck. I'm not sure if the cd errors and the artifact issue are related.
Here is the Buildspec file currently. I've also attempted several different versions of the "files:" statement including - '**/*'
buildspec.yml
version: 0.2
phases:
install:
commands:
- echo Nothing to do in the install phase...
pre_build:
commands:
- echo Nothing to do in the pre_build phase...
build:
commands:
- echo Build started on `date`
- echo $CODEBUILD_SRC_DIR
- uServices/hello-world-java/gradlew build
post_build:
commands:
- echo Build completed on `date`
artifacts:
files:
- uServices/hello-world-java/build/distributions/*
output from the codebuild
[Container] 2019/01/31 14:19:42 Waiting for agent ping
[Container] 2019/01/31 14:19:43 Waiting for DOWNLOAD_SOURCE
[Container] 2019/01/31 14:19:44 Phase is DOWNLOAD_SOURCE
[Container] 2019/01/31 14:19:44 CODEBUILD_SRC_DIR=/codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
[Container] 2019/01/31 14:19:44 YAML location is /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git /buildspec.yml
[Container] 2019/01/31 14:19:44 Processing environment variables
[Container] 2019/01/31 14:19:44 Moving to directory /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
[Container] 2019/01/31 14:19:44 Registering with agent
[Container] 2019/01/31 14:19:44 Phases found in YAML: 4
[Container] 2019/01/31 14:19:44 POST_BUILD: 1 commands
[Container] 2019/01/31 14:19:44 INSTALL: 1 commands
[Container] 2019/01/31 14:19:44 PRE_BUILD: 1 commands
[Container] 2019/01/31 14:19:44 BUILD: 3 commands
[Container] 2019/01/31 14:19:44 Phase complete: DOWNLOAD_SOURCE Success: true
[Container] 2019/01/31 14:19:44 Phase context status code: Message:
[Container] 2019/01/31 14:19:44 Entering phase INSTALL
[Container] 2019/01/31 14:19:44 Running command echo Nothing to do in the install phase...
/codebuild/output/tmp/script.sh: 1: cd: can't cd to /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
Nothing to do in the install phase...
[Container] 2019/01/31 14:19:44 Phase complete: INSTALL Success: true
[Container] 2019/01/31 14:19:44 Phase context status code: Message:
[Container] 2019/01/31 14:19:45 Entering phase PRE_BUILD
[Container] 2019/01/31 14:19:45 Running command echo Nothing to do in the pre_build phase...
/codebuild/output/tmp/script.sh: 1: cd: can't cd to /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
Nothing to do in the pre_build phase...
[Container] 2019/01/31 14:19:45 Phase complete: PRE_BUILD Success: true
[Container] 2019/01/31 14:19:45 Phase context status code: Message:
[Container] 2019/01/31 14:19:45 Entering phase BUILD
[Container] 2019/01/31 14:19:45 Running command echo Build started on `date`
/codebuild/output/tmp/script.sh: 1: cd: can't cd to /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
Build started on Thu Jan 31 14:19:45 UTC 2019
[Container] 2019/01/31 14:19:45 Running command echo $CODEBUILD_SRC_DIR
/codebuild/output/tmp/script.sh: 1: cd: can't cd to /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
/codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
[Container] 2019/01/31 14:19:45 Running command uServices/hello-world-java/gradlew build
/codebuild/output/tmp/script.sh: 1: cd: can't cd to /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
Downloading https://services.gradle.org/distributions/gradle-3.5-bin.zip
..........................................................................................................................................................................................................................................................................................
Unzipping /root/.gradle/wrapper/dists/gradle-3.5-bin/daoimhu7k5rlo48ntmxw2ok3e/gradle-3.5-bin.zip to /root/.gradle/wrapper/dists/gradle-3.5-bin/daoimhu7k5rlo48ntmxw2ok3e
Set executable permissions for: /root/.gradle/wrapper/dists/gradle-3.5-bin/daoimhu7k5rlo48ntmxw2ok3e/gradle-3.5/bin/gradle
Starting a Gradle Daemon (subsequent builds will be faster)
:buildEnvironment
------------------------------------------------------------
Root project
------------------------------------------------------------
classpath
No dependencies
BUILD SUCCESSFUL
Total time: 8.74 secs
[Container] 2019/01/31 14:19:56 Phase complete: BUILD Success: true
[Container] 2019/01/31 14:19:56 Phase context status code: Message:
[Container] 2019/01/31 14:19:56 Entering phase POST_BUILD
[Container] 2019/01/31 14:19:56 Running command echo Build completed on `date`
/codebuild/output/tmp/script.sh: 1: cd: can't cd to /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
Build completed on Thu Jan 31 14:19:56 UTC 2019
[Container] 2019/01/31 14:19:56 Phase complete: POST_BUILD Success: true
[Container] 2019/01/31 14:19:56 Phase context status code: Message:
[Container] 2019/01/31 14:19:56 Expanding base directory path: .
[Container] 2019/01/31 14:19:56 Assembling file list
[Container] 2019/01/31 14:19:56 Expanding /codebuild/output/tmp/script.sh: 1: cd: can't cd to /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
.
[Container] 2019/01/31 14:19:56 Expanded to /codebuild/output/tmp/script.sh: 1: cd: can't cd to /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
/codebuild/output/tmp/script.sh: 1: cd: can't cd to /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
.
[Container] 2019/01/31 14:19:56 Skipping invalid artifact path /codebuild/output/tmp/script.sh: 1: cd: can't cd to /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
/codebuild/output/tmp/script.sh: 1: cd: can't cd to /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
.
[Container] 2019/01/31 14:19:56 Phase complete: UPLOAD_ARTIFACTS Success: false
[Container] 2019/01/31 14:19:56 Phase context status code: CLIENT_ERROR Message: no matching base directory path found for /codebuild/output/tmp/script.sh: 1: cd: can't cd to /codebuild/output/src590503358/src/github.com/SomosEngineering/tss-modern.git
Summary
In my development area I can run Gradle and see the .zip artifact
sitting in the following directory as below. I would expect codebuild
to find it and load it to S3. [clipford#NVA-1a-TSS-DEV01
distributions]$ pwd
/home/clipford/work/tss-modern/uServices/hello-world-java/build/distributions
[clipford#NVA-1a-TSS-DEV01 distributions]$ ls
tss-modern-clipford.zip
I ended up attempting to build this from an amazon S3 container the build worked completely. Then I went back to the GitHub version and the issue associated with not being able to cd to the codebuild directories magically went away. (I don't believe in magic either but assume that it was an amazon issue).
The Issue with the artifact not loading was related to the fact that the artifact in our project sits in a directory that is not part of the GitHub repo. It's actually ignored in .gitignore. The artifact directory is created at build time and it appears that since it's ignored in the .gitignore and not part of the repo codebuild doesn't find the artifact and can't load it to S3.

aws code-build fails on build step image is missing

Hi I'm running the aws code pipeline since months now.
Now I got an error:
./buildspec_build.sh: line 5: cd: target/docker/stage: No such file or directory
Sending build context to Docker daemon 194.6 kB
Step 1 : EXPOSE 9000
Please provide a source image with `from` prior to commit
[Container] 2017/11/16 15:23:13 Command did not exit successfully chmod +x buildspec_build.sh && ./buildspec_build.sh exit status 1
[Container] 2017/11/16 15:23:13 Phase complete: BUILD Success: false
[Container] 2017/11/16 15:23:13 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: chmod +x buildspec_build.sh && ./buildspec_build.sh. Reason: exit status 1
[Container] 2017/11/16 15:23:13 Entering phase POST_BUILD
[Container] 2017/11/16 15:23:13 Running command echo "*** POST-BUILD:"
*** POST-BUILD:
[Container] 2017/11/16 15:23:13 Running command chmod +x buildspec_postbuild.sh && ./buildspec_postbuild.sh
The push refers to a repository [.dkr.ecr.eu-central-1.amazonaws.com/......]
An image does not exist locally with the tag:
My build file looks like this:
#!/bin/bash
# make code ready for docker
sbt docker:stage
cd target/docker/stage
# add port for aws to dockerfile
echo "EXPOSE 9000" >> Dockerfile
# generate docker image tag
docker build -t "$(cat /tmp/build_tag.out)" .
What is my fail? Has aws changed something?
Thanks in advance
The first error seems to be that a required folder is missing
./buildspec_build.sh: line 5: cd: target/docker/stage: No such file or directory
is this supposed to be created manually or by the previous command?
sbt docker:stage
problem was a wrong sbt version. aws changed it.