2
votes

I have AWS CodePipline with these steps:

enter image description here

When I run CodeBuild phase manually 2 artifacts successfully uploaded to the s3.

enter image description here

When I change code and push it to CodeCommit pipeline executes successfully, but artifacts don't upload to the S3 bucket. When I read the pipeline logs it asserts that 2 files uploaded successfully to the S3 bucket. but files are not in the S3 bucket.

Both Pipeline and CodeBuild use the same S3 bucket. these are Pipeline logs. The last 3 lines of log assert that 2 artifacts successfully uploaded to the S# bucket.

Container] 2020/08/24 08:25:55 Phase complete: POST_BUILD State: SUCCEEDED
[Container] 2020/08/24 08:25:55 Phase context status code:  Message: 
[Container] 2020/08/24 08:25:55 Expanding base directory path: ./build-artifacts
[Container] 2020/08/24 08:25:55 Assembling file list
[Container] 2020/08/24 08:25:55 Expanding ./build-artifacts
[Container] 2020/08/24 08:25:55 Expanding file paths for base directory ./build-artifacts
[Container] 2020/08/24 08:25:55 Assembling file list
[Container] 2020/08/24 08:25:55 Expanding **/*
[Container] 2020/08/24 08:25:55 Found 2 file(s)
[Container] 2020/08/24 08:25:56 Phase complete: UPLOAD_ARTIFACTS State: SUCCEEDED
[Container] 2020/08/24 08:25:56 Phase context status code:  Message: 
2
I read this post before, but it does not help stackoverflow.com/questions/49291962/…Vahid Jafari
Have you checked CodePipeline bucket? CodeBuild should use it to deploy artifacts. It will be zipped and have some random name without an extention.Marcin

2 Answers

3
votes

As explained in the comments, the reason why you can't see the artifacts in your bucket is that CodePipeline (CP) will store it in CP's bucket. You can inspect the CP's bucket.

The artifacts will be zipped, although the file in the bucket will have no extension and will have a random name. You can download the file, add zip extension and unpack to verify.

One way to deploy to S3 is through a Deploy action and Amazaon S3 action provider. But this will just deploy the zip, it will not unpack it. I don't think this is what you are aiming for.

The alternative is to use AWS CLI in your CodeBuild project to simply copy "manually" the artifacts to the desired bucket. This probably would be the easiest way.

0
votes

CodePipeline will override the CodeBuild's artifact bucket, I guess it's moving the artifacts to its own Bucket. you can see the CodePipeline's bucket by running the below command.

codepipeline get-pipeline --name PipelineName--query pipeline.[artifactStore]

[
    {
        "type": "S3",
        "location": "codepipeline-us-east-1-xxxxxxxx"
    }
]

If you are using CloudFormation to create the pipeline you configure the bucket using ArtifactStore.

Update ArtifactStore in CodePipeline: Currently, I don't see a way to update the ArtifactStore through Console but it can be done with update-pipeline command.

Get the pipleline details:

aws codepipeline get-pipeline --name MyFirstPipeline >pipeline.json

Edit the pipeline to update the S3 Bucket in artifactStore and then run the command.

aws codepipeline update-pipeline --cli-input-json file://pipeline.json

Answer Reference: https://stackoverflow.com/a/49292819/11758843