Setting up nightly builds on Shippable

- By Chetan Tarale

BACK TO BLOG HOME

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. 

asset-b6810cc2f24df650901c3fa6f00171d7.png

 

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.

 

 asset-866b98bde7237b991cefb2b2b3d68927.png

 

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 shippable.jobs.yml files to your sync repo.
To create a time resource define the resource in your shippable.resources.yml as shown below.

resources:
 - name: nightly-trigger
   type: time
   seed:
     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.

 

jobs:                                    
 - name: sample_node_runCI              
   type: runCI                         
   steps:                               
     - IN: nightly-trigger              
   on_success:                          
     - script: echo 'on success !!!!!'  
   on_failure:                          
     - 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.

 asset-eba9e747b4d31b9df353fa7c21edf329.png

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

Resources

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