Improvements For Code Build

How to do code build? What things we need to pay special attentions to? Here are my thoughts and sharing.

Post Permanent Link: http://www.dennyzhang.com/improve_code_build/


What counts for a good code build system?

  • Build toolkit can be setup easily and automatically, to avoid unexpected failures.
  • All the necessary packages, dependencies and SDK shall be able to be installed easily. And the version should be the exact version which it should be. One good practice is setup by automation tool (like Chef/Puppet) or creating docker images.
  • People should be able to check env version, after code deployment.
  • To achieve it, we can ask code build process to generate this info to a version file. When code deployment, push the version file as well.
  • Here is an example:
root@e3aab3fd9ae8:~# my_status_all.sh
========= Check services ============
* couchbase-server is running
* elasticsearch 1.5.0 running with PID 23520
* myapp master running with PID 22881
=========== About Code ==============
Build From master branch of mdm repo.
Revision: ec1a6a716b7ba49e7c12de6490aa213b541e7d95
Build Time: 2015-06-08 13:34:51
Jenkins Job: BuildCodeRepo:#603 on 104.236.159.226
  • Leave the build logic to dev team, by hosting build command in SCM repo
  • The whole build process would be install build toolkit, checkout code and run a given command or a given bash script. Build commands may change from time to time. And dev team actually drives the changes. Ideally we can ask dev team to provide the build command. If dev team are too busy for this task as always, devops can define one and storage it in somewhether both dev and devops can check and change.
  • Keep latest old built packages
  • People may want to try to deploy old build, when regression issues happens. Since each build will generate new packages, it will eat up your disk. Thus we need some data retention logic for old built packages.
  • Conditional build: Skip build, if no code change since last build.
  • Build process takes minutes to hours. If no code change, rebuilt is just a waste of time. This is especially true, if you have enabled hourly build.
  • When you have enabled this, make sure you give people a way to force a clean build. This means even if no code change, I want to do the code rebuild anyway.

Here is an example of Jenkins code build job with all above requirement met:


What motivates you to our blog? Let us know on Twitter or Weibo (@dennyzhang001).

Like our blog posts? Subscribe.

By Denny 06/17/15