AWS CodeBuild

AWS CodeBuild provides compute resources that allow you to build, test, and package your software to create artifacts. It runs the continuous integration part of the puzzle by supplying managed build environments. These are pre-built Docker containers, and there's a whole range of containers for the language and versions that you're building for. You can also supply your own build container. When a build is run, your containers can scale so that you have multiple builds running in parallel. This means no more waiting in the build queue! 

Creating a build project is easy:

  • Pick your build container
  • Add some basic configuration
  • Tell CodeBuild where the project instructions are

These instructions are specified along with your code source in a file called buildspec.yml. In this file, you can include all of the commands that you want to run inside the container to build, test, or package your source. Within this file, you can specify various phases as well: 

  • Install: This is used for installing the necessary development packages that your build might need.
  • Pre_build: This command is run before the actual build.
  • Build: Here, you would include your build command sequence.
  • Post_build: This is used to package up any artifacts that the build might have created.

These phases give you quite a lot of flexibility for implementing your custom build process. It's also a good idea to add an echo statement to each of these phases to explain the process that is happening. Stdout will be viewable in the logs that are created. 

When using CodeBuild with Serverless Framework projects, we can run the entire build, package, deployment, and test from one CodeBuild job. If you wanted, you can also split the testing into a separate CodeBuild project as well. The types of testing you might do here include linting to check for syntax errors, any checks on coding standards, unit tests, and even functional end-to-end tests.

For building Node.js and Python services, you would use npm install to source all of the libraries and dependencies that are needed. All the dependencies must live in a folder called node_modules at the project root level. 

For Java, a good way to source dependencies would be to use Maven or Gradle. Compiled classes and other resources should live at the root level and any other .jars that are required should be in a /lib directory. The packaged ZIP file can contain the function code and dependencies or a standalone .jar.

For C#, we should use NuGet, which is the package manager for .NET applications. Again, all of the assemblies should live at the root level and the ZIP package can hold either the function code and dependencies or a standalone .dll file.

A good pipeline always starts with a source code repository. Next, we will introduce one that is native to AWS.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.124.177