I have a CodePipeline project hosted in a CodeCommit Git repository and built by maven. This repository is compiled using CodeBuild and the built artifact is uploaded to ECR. Pipeline has a stage to compile the code and then a separate one to upload the built artifact. I have problem with the later CodeBuild stage saying it is unable to get the artifact. The communication between the stages is using a S3 bucket.
First CodeBuild stage buildspec: (to compile the code)
artifacts:
files:
- rest.war
- pomversion
name: GF_APP
Second CodeBuild stage buildspec: (create docker image)
build:
commands:
- echo Building the Docker image...
- ls -l $CODEBUILD_SRC_DIR_GF_APP
- cp $CODEBUILD_SRC_DIR_GF_APP/*.war .
Error:
[Container] 2019/11/18 16:53:12 Running command echo Building the Docker image...
Building the Docker image...
[Container] 2019/11/18 16:53:12 Running command ls -l $CODEBUILD_SRC_DIR_GF_APP
total 45252
-rw-r--r-- 1 root root 46332873 Nov 18 15:49 rest.war
-rw-r--r-- 1 root root 14 Nov 18 15:49 pomversion
[Container] 2019/11/18 16:53:12 Running command cp $CODEBUILD_SRC_DIR_GF_APP/*.war .
cp: cannot stat '/*.war': No such file or directory
It can seen that a war file exists in the directory, doesn't seem like any permissions is missing. Both CodeBuild projects use the same role and have permission to read S3 bucket where the artifact is stored. The CodePipleline project also has enough permissions to read and write into the bucket, which is encrypted using the default aws/s3 KMS key.
Any pointers on why the CodeBuild fails to find the file? I have also tried giving the whole name of the artifact, doesn't help though.
Thank you.