6

I am trying to set up automatic deployment for the Angular 2 app with AWS Pipeline, S3 and CodeBuild.

Following Andrés' tutorial I was able to connect CodeBuild the GitHub repo and the process works great.

However, our Angular app lives inside a subdirectory of the bigger repo.

Is there a way to specify a directory inside a repo, so that the build will only be triggered if the subdirectory changed?

Thanks a lot.

2 Answers 2

12

If you are using GitHub webhooks in CodeBuild, you now have a file_path option, which will allow you to trigger the build only when a specific file or directory is changed.

Documentation: https://docs.aws.amazon.com/codebuild/latest/userguide/sample-github-pull-request.html#sample-github-pull-request-filter-webhook-events-console

Sign up to request clarification or add additional context in comments.

2 Comments

@IlyaKrasnov this should be the accepted answer now.
Thanks for the link, it works fine for codebuild however when I connect codebuild to codepipeline, codepipeline ignore the file_path trigger which is sat up on codebuild. code pipeline will be triggered by any push to the repo. Do you know if there is any way to limit the codepipeline trigger by file_path as well?
2

It doesn't look like you can just pull down a certain folder but the artifact for the build spec you can specify the directories that are used for the build.

For GitHub, for the optional Source version value, type a commit ID, a pull request ID, a branch name, or a tag name that corresponds to the version of the source code you want to build. If a pull request ID is specified, it must use the format pr/pull-request-ID (for example, pr/25). If a branch name is specified, the branch's HEAD commit ID will be used. If Source version is blank, the default branch's HEAD commit ID will be used.

http://docs.aws.amazon.com/codebuild/latest/userguide/run-build.html

artifacts Optional sequence. Represents information about where AWS CodeBuild can find the build output and how AWS CodeBuild will prepare it for uploading to the Amazon S3 output bucket. This sequence is not required if, for example, you are building and pushing a Docker image to Amazon ECR, or you are running unit tests on your source code but not building it. files: Required sequence. Represents the locations containing the build output artifacts in the build environment. Contains a sequence of scalars, with each scalar representing a separate location where AWS CodeBuild can find build output artifacts, relative to the original build location. Locations can include the following: A single file (for example, my-file.jar). A single file in a subdirectory (for example, my-subdirectory/my-file.jar or my-parent-subdirectory/my-subdirectory/my-file.jar). '/' represents all files recursively. my-subdirectory/ represents all files in a subdirectory named my-subdirectory. my-subdirectory//* represents all files recursively starting from a subdirectory named my-subdirectory.

http://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html

2 Comments

Thanks, @strongiz. We solved the issue using a subtree and a separate repository for the pipeline.
and now you have 2 problems ;-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.