9

What I'm trying to do is to create a following CI flow with standard AWS tools: run a build of a commit when a Pull Request in Github is created or updated. Or run a build of any branch on my command. Very similar to what Codeship, Travis and many other CI services offer.

Is it possible with CodeBuild + CodePipeline? I noticed that I have to specify exact branch in CodePipeline and, unfortunately, could not find how to integrate Github Pull requests into it. Maybe I overlooked it?

2
  • CI implies that builds are automatically triggered. I don't see how to setup an automated trigger in either CodeBuild or CodePipeline. So confused. Commented Dec 5, 2016 at 12:05
  • Once I add a branch to code commit, it does seem to trigger a build in pipeline. I'm also curious how to do this automatically on Pull Requests. In Jenkins we use ${sha1}. What's weird is that in Github I don't see any integrations or webhooks listed even though CodePipeline is clearly seeing changes. Commented Dec 5, 2016 at 18:03

4 Answers 4

5

CodeBuild now directly supports building GitHub pull requests (without Lambda intermediate step), if you're looking to simply run a build as part of the PR. For running more steps with CodePipeline as part of a PR, you'll still need to set up some scaffolding as the other answers suggest. https://aws.amazon.com/about-aws/whats-new/2017/09/aws-codebuild-now-supports-building-github-pull-requests/

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

3 Comments

A link to a solution is welcome, but please ensure your answer is useful without it: add context around the link so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. Answers that are little more than a link may be deleted.
I think this DOES answer the question and does include the essential parts of the answer. Bit trigger happy with the comments here.
Updated answer with more context
4

CodePipeline does support basic, fully-managed integrations with both GitHub and CodeBuild, as listed in Product and Service Integrations with AWS CodePipeline. With these integrations, it is possible to use CodeBuild with CodePipeline to run a build of a commit when a commit is pushed to a branch on GitHub. See Use AWS CodePipeline with AWS CodeBuild to Run Builds for details on integrating CodeBuild with CodePipeline as a Build action provider, and see the Four-Stage Pipeline Tutorial for details on integrating Github with CodePipeline as a Source action provider.

Currently, the Pull Request feature in Github is not supported in the official CodePipeline integration, you did not overlook anything. For an interesting AWS-ecosystem open source project (not yet v1.0) that does support GitHub Pull Request integration (though not yet CodePipeline), you might want to check out LambCI.

Comments

2

It looks like this can be done somewhat manually by using Lambda and S3 - https://aws.amazon.com/blogs/devops/integrating-git-with-aws-codepipeline/

Webhooks notify a remote service by issuing an HTTP POST when a commit is pushed to the repository. AWS Lambda receives the HTTP POST through Amazon API Gateway, and then downloads a copy of the repository. It places a zipped copy of the repository into a versioned S3 bucket. AWS CodePipeline can then use the zip file in S3 as a source; the pipeline will be triggered whenever the Git repository is updated.

3 Comments

Oh... Too many moving parts to maintain. No thanks, Amazon, I'll rather stick to Codeship then :)
This blog post covers integrating AWS CodePipeline with third-party Git-repository webhooks ('GitHub Enterprise, Bitbucket, GitLab, or any other Git server'), and has nothing to do with GitHub's Pull Request feature.
Greetings from the future! In fact, you can now (as of fall, 2017) select Github as a CodeBuild source, as @Clare Liguori states below. This will auto run a AWS Codebuild build when you push to a repo, and update the buildstatus as appropriate. See their notes on AWS Codepipeline, but I know CodeBuild Just Works...
-2

You could try https://www.deploytoproduction.com for Github Pull Request build status integration with AWS CodeBuild. It is free for a single Github repository with a subscription plan available for multiple repositories. The service doesn't currently integrate with CodePipeline but that is coming soon.

PR Build Passed Screenshot

If you wanted to build something yourself, you could make a new integration on GitHub that uses the webhook functionality to trigger a lambda function which in turn triggers your CodeBuild jobs or pushes an artifact to S3 to start a CodePipeline.

Full disclosure I am the author of this service

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.