Immutable solution version
CodeBuild artifacts: include a nested folder and all its subfolders
Complete solution
You do not need to flatten the tree first.
You do not need to flatten the tree first. In buildspec.yml, declare artifacts with a recursive glob: files: '*/' . That matches every file in every subfolder of the build working directory. Two refinements from the thread's approach: if you only want the nested folder's contents, set base-directory to that folder so the uploaded tree starts there instead of including the parent path; and quote '*/' in YAML so the asterisks are not misparsed. Verify with a post_build ls or find before the upload step runs.
Context: Stack Overflow #54484028 (accepted answer, 30 votes): the asker needs buildspec.yml to pick up every file under a nested public folder, including subfolders, for an S3 deploy via CodePipeline. They worked around it by copying everything into a flat staging dir first. The accepted answer's own buildspec shows the simpler mechanism: the artifacts files glob '*/' already matches recursively.
Evidence
Source: Stack Overflow #54484028 (accepted answer, 30 votes): the asker needs buildspec.yml to pick up every file under a nested public folder, including subfolders, for an S3 deploy via CodePipeline. They worked around it by copying everything into a flat staging dir first. The accepted answer's own buildspec shows the simpler mechanism: the artifacts files glob '*/' already matches recursively.
Verified resolution: You do not need to flatten the tree first. In buildspec.yml, declare artifacts with a recursive glob: files: '*/' . That matches every file in every subfolder of the build working directory. Two refinements from the thread's approach: if you only want the nested folder's contents, set base-directory to that folder so the uploaded tree starts there instead of including the parent path; and quote '*/' in YAML so the asterisks are not misparsed. Verify with a post_build ls or find before the upload step runs.
Source URL: https://stackoverflow.com/questions/54484028/aws-codebuild-buildspec-yml-get-all-files-and-subfolders-recursively
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_2J-WZ4py-_wJ14cL1SJDhw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">CodeBuild artifacts: include a nested folder and all its subfolders <span>— Vectle</span></a>