Search The Blog
My Books

New:

My Songs

 

The Art of Unit Testing

Buy PDF or Print book at Manning

Buy on Amazon

Latest Posts
from 5whys.com
Twitter: @RoyOsherove
About this site

TDD in .NET Online Course

TDD and BDD in Ruby Online Course

 

Subscribe!

This site aims to connect all the dots of my online activities - from tools, books blogs and twitter accounts, to upcoming conferences, engagements and user group talks.

« Build Bullets #2–Avoid XML Facing Build Tools | Main | The Three Values of a Good Isolation Framework »
Saturday
Nov172012

Build Bullet #1 - Use Version Aware Build Scripts

I am thinking of writing a small booklet about better builds. this blog post might end up as a part of it. Let me know if you’re interested by taking a look here.

While I do love to use Continuous Integration Servers such as teamcity, Jenkins and more, I try to use them as much as possible as “dumb triggers” to my build actions. They do one thing and one thing only, and that is to trigger the correct build script with the correct resources (source version, artifacts form other builds, etc), and nothing more. 

I don’t add any custom build actions such as compilation, source checking etc, because I believe that the build actions themselves have a very strong connection with the correct version of the source.

For example, at an earlier version of the source you might need to compile a specific set of projects, and in future source versions, maybe new projects were added, some were removed, or renamed etc.  If you have your build scripts as part of your source control, and versioned along with the source, they will always match the current source version.

 

zZhRk5owEMc/jY/tkICcPJ6ctH3oTGeuM31OJWKmkTgh3ul9+oKJSMxyJxptxxkkGwjZX3Y3fxiF6Wr7RZL18rvIKR/hIN+OwqcRxpMgqI+NYXdiKCTLtQkZw4bltLJMSgiu2No2zkVZ0rmybAvB7cHWpKCO4XlOuGv9xXK1NJPD8dH+lbJieXgMihPdU6ndYYycLsiGq097E9bd20D3hebynWmPk8PApTWBNyFWlkHSir3Zk1wwMwtD7reQOZWWibPyT5dSOBuFqRRC6bPVNqW8WZYDcn1b1tPbwpG0VOfcYJx/IXxjpp5+q9s/pJjTqnLAVa9sxUlZt6aFJDmrn5IKLrRLYZal+HHiTsHM6oVKRbenvtbhR8WKKrlrFsGsQWzomNA7NF+PCx5FxrbsLHZ0oEoM0qId+sigPjEYYCQhjGS6YXWk4iAV5YIVLpklWTenav83XTDOO2TSNJtkmUsGDyWDQpvM2CXTXtIlgwIPZCKHzBNhfOfA2UiimCg/YgREUBxPsRdOiY0JARHU2rxzGruc6JqL3b4u1oeftFKjJlQHBhUALEnqpEt9BBYaW8Ragl1iya2IxQ6xZ7GRc6rRKCmai1/Q52BgRUqjdAbF0+CKFH1YkMLgVgVp0g8nY5wCVdqEzZJuSVHnIYhmFjc/F008FM2DjSYC4gYDaCYeyKDArdWsk1bPc8nWqpdPKdQ7aQXFzWA4J3GDoHo9AejEPuggh85pvb4YUF+hvhYQDgFAD7cC5KofsFB7CSeoSl9Lq605HVoY2v590MJusjkoaJk/Sile9zTqotxXeCtdwLp6SxFZ0HZP0TaaW+8CLpar/HHTw4s/EeAPuoc/bjR78WcM+IPv4Y8rxGFRgBw3zxcFTuoBOPqz0ZZMY3RPVQCocd+y4AM4eoH+R10AKHD/uuA6Ov9SGABy+ybCwCuhuyoD/OASurky8IrrvtLAfUU5b+s52UAu2Yv0UnneepI7+QNoBZ2cfv0JL5VuQ/0BtJxes6v8qZvHL6L7vs4X63D2Fw==

 

So what do those processes trigger? A script that is inside source control, tied directly to the current project`s source committed version. It might be an xml file (ugh), or a rake file, or a finalbuilder script file (my favorite).

Then it becomes easier to revert to an older build version to recreate it, or to test differences between versions, or to build multiple different branches of the same applications in parallel for different clients.

See if you can take your current CI build, and have it run on a version of the source from 6 months ago. How many changes will that require of you to make it work? If your build is tied to source version, things should feel much simpler.

Single Responsibility

To me it is also about the single responsibility principle.  A Continuous Integration server should do one thing well – manage builds, their resources, and their scheduling.  It should not also need to worry about what is inside each build. In uncle bob’s newspaper metaphor, the builds would be like different sub headings. Each does one thing, and the caller of those functions would only call them, without caring what they do.

 

Thinking about it the other way around, if you have your whole build script running inside one large set of teamcity custom actions, all managed in the browser, and then you refactored that script to separate script files that are part of the source code, you’d be closer to what I am trying to do.

 

So when I see companies boasting about how many custom tools their CI server can do, and how you can manage it all in the browser easily, I remind myself that the more I use those custom build features without the context of a current source version they are attached to, the more work I will have to do to change them every time I need to go back and forth between versions.

 Version Aware Artifact Paths

Following that line of thinking, I might argue that version aware build script “cubes” in source control should also be internally-deciding on what artifacts the encompassing CI process that is running them will be exposed to, and allowed to share with other builds. Today such things are managed solely at the CI tool level, but it would be good if the tools enabled artifact paths to be tied to the current version of the source.

PrintView Printer Friendly Version

Web Analytics