logo logo

What Are The Benefits of Having Nightly Builds

main post image

What is a Nightly Build?

A nightly build is a neutral build that typically takes place when no one is likely to be working in the office. In addition, there are no changes to the source code during the build. It takes place automatically every night. All pieces of code that have been checked into source control is built.

The term is frequently used for large projects. In such projects, a complete rebuild of the finished product from the source takes too long for the individual developer to do this as a part of their regular development cycle. Hence, software that is not built regularly is difficult to release – that’s why the teams need the nightly builds.

How to Build The Pipeline?

There are tools, that can help to deal with nightly builds infrastructure. The most popular are Jenkins and TeamCity. It is great to have a DevOps specialist on board, who will be able to help in constructing the pipeline.

The main goal is to deploy the code, run a set of unit tests, smoke tests, and integration tests, if applicable and get the result from some kind of report. For the customer-facing or management point of view – the more colorful and visual the report – the better.

Here is an example of how the build pipeline could be built:

  • HEAD of the branch is checked out to Jenkins slave node,
  • HEAD of the branch is built on Jenkins slave,
  • JUnit tests are run,
  • Static code analysis is run against quality gates,
  • HEAD of the branch is deployed to TEST environment,
  • Smoke tests are run against TEST environment,
  • An artifact is created and tagged,
  • A Build in Jenkins is Commented with a Tag (the same as an artifact).

An interesting fact worth mentioning is that with TestProject‘s free test automation platform you don’t even need a DevOps specialist to build your CI pipeline, since with TestProject you already have a built-in simple Jenkins Integration, or you can utilize their RESTful API swagger to easily trigger your automation

Why Are The Nightly Builds Useful?

The nightly build should increment the version and stamp everything with the correct version number. The most convenient is that the re-build environment is ready for the developers coming in the next morning. They can continue working on their tiny bit on top of the new version. 

Nightly builds also ensure that the build tools have not broken due to system updates, and are therefore often run whether any source code has changed or not. Of course, whenever the team uses Jenkins or any other tool to run builds on it, there has to be someone responsible for the maintenance and stability of the environment. It may be tricky, especially at the beginning of the project. On the other hand, when the nightly build is introduced later, it helps to obtain better quality and reliability of the code.

Nightly builds reveal problems with the code in the early stages of work in the project. In addition to this early-testing and early-integration based approach, the nightly build is performed automatically at the end of each day of development, so it not only covers all code changes committed to the develop branch during the working day but also contains always all automated unit, integration, and E2E tests.

From the nightly build results we can derive two types of quality statements

  • What is the quality of the committed code?
  • How is the health of the build and test infrastructure?

Do The Product Benefit From The Nightly Builds? 

It is sometimes hard to convince the management that the effort to build preparation is worth to invest. Even when the developers and the testers benefit from having nightly builds. In short, they quickly know what is the state of their version and are sure if it’s deployable to production.

The team has to know the value of the effort required for building the pipeline. One or more person has to invest time and does some maintenance as well after introducing the nightly build.

What is more, the “problem” with the nightly builds is that the benefits usually remain transparent for the management. In addition, the product can benefit from the seamless releases but doesn’t see the hidden effort. That’s why it is sometimes hard to persuade the management that the money invested in CI/CD pays off.

How to Convince The Management that Nightly Builds Are Necessary?

The main benefits form having the Nightly Builds:

  • The code that has been committed during the last day can be tested and reveal any recent problems (with the code, tests or the infrastructure), it is easy to identify the root cause of each problem.
  • Each build ends with a ready artifact that could be used for a release candidate for deployment.
  • Bugs in the baseline code of the Develop branch are found and fixed before they contaminate new branches. What is more, getting to the root cause of the problems is much easier if we have to consider only 1 day, and not analyze the whole week back.
  • Problems in the build, test, and deployment infrastructure are identified early and can be addressed and corrected at the beginning of a working day, which minimizes the negative impact on the team.
  • The build is repetitive, so it is easy to compare two or more consecutive builds to look for the root causes of the problems.
  • People don’t have to remember about running the build, as it runs automatically, it helps save time.
  • There is a report available each morning about the current status of the code and environment – it helps in fast problem-solving.
  • The build runs during the night, so it doesn’t interfere with the regular development and deployment, it doesn’t occupy the environment.

Nightly Builds Help to Ensure that The Codebase Stays Healthy 

A side effect of doing nightly builds is that it forces the team to create and maintain a fully automated build script. This helps to ensure that the build process is documented and repeatable.

What is more, automated builds are good at finding the following problems:

  • Somebody checked in something that breaks the build.
  • Somebody forgot to check in a necessary file or change.
  • The build scripts no longer work.
  • The build machine is broken.
  • Necessary certificates expired.

We may argue about the kind of testing we need in software projects.

Some of the testers and developers will strongly opt for exploration, some for test automation or sets of manual checks. Nevertheless, in the modern software projects, a nightly build is a must, if the team would like to rely on their code base and would like to continuously release their software into production. In short, it is worth to invest the effort and build a stable nightly build pipeline.

 

Avatar

About the author

Kinga Witko

Professional Quality Evangelist, experienced in testing web and mobile applications.
Since 2013, when my adventure in Quality Assurance began, I worked as a Tester, Test Lead and Product Owner. Currently, I work as a Test Manager in an automotive project in Capgemini Wrocław, taking care of quality and processes. Blogger. Conference speaker.
I wish every application to be accessible. I love cats, great design and sci-fi movies.
I am curious about novelties in astronomy and new technologies.

Join TestProject Community

Get full access to the world's first cloud-based, open source friendly testing community. Enjoy TestProject's end-to-end test automation Platform, Forum, Blog and Docs - All for FREE.

Join Us Now  

Leave a Reply

Join TestProject Newsletter

Join a 20K community of readers! Always stay up-to-date with all the latest test automation trends, best practice and tips shared by leading software testing community experts across the globe!

FacebookLinkedInTwitterEmail