amazon-web-servicesaws-codebuildbitbucket-aws-code-deploy

Is bitbucket enterprise server allowed with AWS codebuild?


I am looking to integrate enterprise bitbucket server with aws ci/cd pipeline features.

I have tried creating a project within aws codebuild but do not see any option for bitbucket enterprise .

If this is not possible then what is the long route using api gateway / webhooks etc ?


Solution

  • AWS Codebuild only supports the Bitbucket cloud. To integrate with Bitbucket self hosted solution, you will need to create a API gateway + Lambda. And then add this gateway address as a webhook in the bitbucket repo. The Lambda will then be responsible to process the incoming events from Bitbucket server. There could be 2 routes from here.

    One way could be to download the zip for the particular commit and upload it on a S3 bucket. Add S3 as a source trigger for the build project. You lose the ability to run any git specific commands in such a case though as it's just a zip file containing the specific version of files.

    Second option could be to pass on the relevant info to codebuild by directly invoking it from Lambda. Passing off details like commit_id, event (pr or push), branch etc as environment variables. Based on this info, run a git clone in codebuild before running other build steps. This way you would have access to git specific commands.

    Here is an example workflow from AWS (it is for codepipeline, but you can modify it suitably for codebuild)