Search code examples
amazon-s3aws-codebuild

How to store CodeBuild output artifact in S3 bucket folder with the folder name as build-date


I have a codebuild project which creates a binary distribution wheel stored in the dist directory.

My Codebuild project buildspec [relevant lines]

artifacts:
  files:
    - "*.whl"
  name: $(date +%Y-%m-%d)
  #discard-paths: yes
  base-directory: 'dist'

Artifacts

  • Type: S3
  • Bucketname:
  • Name:
  • Path: path/to/folder/in/s3/bucket
  • Artifact packaging: None

The codebuild project runs successfully but the output artifact is not in the directory with the date.


Solution

  • In order to use the folder name as defined in the buildspec.yml, the semantic versioning needs to be enabled.

    I had to enable that in the Artifacts section of the CodeBuild projectenter image description here