Matteo
Matteo

Reputation: 2624

How do I exclude a folder from AWS Codebuild buildspec file?

So I need to exclude a folder from my artifacts, but googling around could not find any info.

version: 0.2

phases:
  install:
    runtime-versions:
      nodejs: 10
  build:
    commands:
    - echo Build started on `date`
     - echo Compiling the Node.js code
     - mocha test.js

  post_build:
    commands:
      - echo Build completed on `date`
artifacts:
  files:
    - '**/*'

Upvotes: 2

Views: 6051

Answers (3)

Vera Stoyanova
Vera Stoyanova

Reputation: 81

buildspec.yml currently support excluding paths in the artifacts section.

  artifacts:
    exclude-paths: 
      - ./**/someFilePatternHere
      - ./**/otherFilePatternHere

It follows the same logic as the files: section but does exclude particular files. See: https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html#build-spec.artifacts.exclude-paths

ps: exclude-paths is relative to base-directory property.

Upvotes: 8

Marcin
Marcin

Reputation: 238209

buildspec.yaml does not provide a way to skip some files or folders when constructing artifacts.

Thus, based on the comments, the easiest solution to the problem was to simply delete unneeded files and folders in the post_build stage.

Upvotes: 4

RAJAT MALIK
RAJAT MALIK

Reputation: 17

1 Solution = exclude in .gitingnore file. 2 Solution = add this in below your code. Let me know if it works

artifacts: files: - '**/' excluded_paths: - foldername/

Upvotes: -1

Related Questions