Setting up nightly builds on Shippable

- By Chetan Tarale on March 18, 2017

Nightly builds means running an automated build for a project once a day, usually after the end of the day. It is often a good practice run automated builds every time you make some change to your codebase. These automated builds help you maintain a healthy code base.

Automated builds help in finding out a number of problems like:

  • A team member checked in something that breaks the codebase.
  • Your dependencies have changed and they break your code.
  • Your dependencies are broken.
  • Your build scripts or build machine is broken. 

Nightly builds ensures that you catch such problems within 24 hours of when they occur.


Setting up your project for nightly builds

Enable your project from the shippable UI. 



Now on navigating to your pipelines tab you can see your project linked to its dependency on SPOG. Shippable has created a resource named  sample_node_ciRepo and a job sample_node_runCI.




Next to run builds periodically you will need a resource that will trigger builds for you. Shippable supports several resources that are predefined as part of the platform. The resource that will run tasks periodically at fixed times, dates, or intervals is the `time` resource.This resource can be used used as an IN input for any job.

To define your resources and jobs add shippable.resources.yml and files to your sync repo.
To create a time resource define the resource in your shippable.resources.yml as shown below.

 - name: nightly-trigger
   type: time
     interval: "0 22 * * *"  # this field accepts cron like syntax

This creates a resource that will trigger a job everyday at 22.00 hours everyday. 

Now that you already have a job named sample_node_runCI.  Now you just need use the time resource as IN for the  job you want to run, sample_node_runCI in this case.


 - name: sample_node_runCI              
   type: runCI                         
     - IN: nightly-trigger              
     - script: echo 'on success !!!!!'  
     - script: echo 'Failed job .... :('


Next add the sync repo from the shippable UI. This will create your time resource and link it to your CI job.


That’s it!. You have set up nightly builds. The time resource will trigger the CI job at the specified time interval.


Topics: continuous integration (CI), Shippable updates, features