Whenever you see a skyscraper, you can be sure there are deep foundations underground ensuring it is sound and stable. Similarly, whenever you see a CI/CD pipeline working properly, there must be a solid build automation system running underneath. Build automation systems can take commits made by developers, add them to an existing codebase and quickly build a software system, allowing it to be tested and, when ready, deployed to production.
In this article you will learn:
What Is Build Automation
A software build is a process that takes source code and other artifacts created by developers, and turns them into a software product that can be executed and used by customers. The build may include any of the following steps:
- Compiling source code (in compiler-based languages like C++ or Java)
- Compressing target files into archives (such as JAR, ZIP or WAR)
- Generating software installers
- Running automated tests on the build
- Automatically deploying software on a target environment
Build automation is a basic component of continuous integration (CI) and continuous delivery (CD) pipelines build around a “release early release often” mentality. But on its own, an automated build processes can help development teams by:
- Standardizing builds, eliminating variations between releases and reducing manual work which can lead to defects and deployment issues.
- Documenting and codifying important aspects of a software project, such as third-party dependencies, artifacts included in the build, tests that need to be run before a build can pass, and details of the target deployment environment.
Build automation systems can be triggered in a number of ways:
- Manual build trigger—a developer requests a new build.
- Schedule build trigger—an automatic build from the codebase every hour, day, week, etc.
- Source code build trigger—many teams automatically run a build after every code commit, in line with continuous integration best practices.
- Post-process build trigger—a build can be run each time a specific process completes, for example after a security scan finishes running, although this is not commonly used in CI/CD pipelines, and all build-related processes are typically run as part of the build script.
Types of Builds
Generally, there are two types of builds.
- Full build—builds the entire software application from the source files. It takes in the full project, checks dependencies, compiles all source code and builds the target software components, creating the complete build artifact.
- Incremental build—an incremental build takes an existing build, checks what has changed in the source code and artifacts since the last time the software was built, and compiles or rebuilds any file or artifact that has changed, or which depends on a resource that has changed. Other files will remain unchanged and be reused from the previous build.
Incremental builds are faster and more resource efficient, but are also less reliable.
How Do Build Automation Tools Work?
Build automation tools use a scripting language that allows developers to specify what source code to use, pull in the relevant resources, and perform other actions such as run automated tests or deploy the software.
|Build management UI
||Integration with IDEs
|Source code management
||Integration with testing tools
||Integration with deployment tools
|Version conflict resolution
||Integration with environments like public cloud systems
||Integration with containerization platforms
||Build cache to speed reuse of the same resources
|Build execution and performance metrics
Top Automated Build Tools
Jenkins is possibly the most popular build tool and is commonly used as part of CI/CD pipelines. Features include:
- Plugin ecosystem—hundreds of plugins that integrate with almost all tools in the CI/CD toolchain
- Customizable—you can extend Jenkins using its simple scripting language, or by building your own plugins.
- Distributed architecture—for large build pipelines, you can run clusters Jenkins machines, and also deploy Jenkins on cloud infrastructure.
- Open source—Jenkins is free and open source, and is backed by CloudBees who provides paid support and enterprise features.
Travis CI is a hosted continuous integration service that lets you build and test projects hosted on GitHub. Travis features include:
- GitHub integration
- Cloud-based hosted platform
- Allows Github repos to perform pull requests
- Comes with its own build and test tools
- Can automatically deploy software to cloud services
- Recreates virtual machines after every build cycle
- Encrypt environment variables and sensitive data
- Provides web UI, CLI API access
Maven is a build tool for Java applications. It provides the following features:
- Dependency management including automatic updating, dependency closures
- Large repository of libraries and metadata
- Can be extended by writing plugins in Java or scripting languages
- Uses Ant tasks for dependency management outside of Maven
- Can build projects into predefined output types such as a JAR or WAR based on a model language, with no scripting
- Integrates with source control such as Subversion or Git and manages release of projects based on tags
Ensuring Tests Don’t Slow Down Your Build with SeaLights Test Impact Analytics
In large software projects with millions of lines of code and tens or hundreds of thousands of tests, builds can take a long time to run. Developers are idle while they wait for the build, or have to switch to other tasks and then switch back, which also wastes valuable tasks. This flies in the face of agile methodology, which says that developers should commit frequency and immediately get feedback on their work from the build system.
SeaLights Test Impact Analysis (TIA) is a smart test execution engine that can cut down testing time as part of your build by 50-90%. You don’t need to run the full set of unit, functional and regression tests every time a developer commits new code to the repository. SeaLights Test Impact Analysis can identify and execute the minimum subset of tests required without compromising quality.
SeaLights provides a quality intelligence system that analyzes hundreds of thousands of test executions, code changes, and builds, and identifies which tests are actually needed to test the latest code changes in your build. It selectively runs only those tests, dramatically reducing build time for large software projects.
For more advice on how to increase agile velocity and productivity with quality intelligence, learn more about Quality Intelligence.