15

From the joel test:

Can you make a build in one step?

I've got to say I can't. I'm currently working on a web app that has a spreadsheet list of items that must be carried out in order to deploy. So my question is how can I automate this? Does it have to be organisation wide? Tips/techniques?

Pemdas
  • 5,385
  • 3
  • 21
  • 41
billy.bob
  • 6,549
  • 4
  • 29
  • 45
  • 3
    It depends what the items in the list are? Ideally, yes you should be able to automate it. – Nobody Jan 13 '11 at 12:29
  • 4
    http://en.wikipedia.org/wiki/Build_automation BTW: Some stay one step is one too much :) – Mchl Jan 13 '11 at 12:30
  • All sorts - move files over, script out stored procedures etc - there are 14 steps! – billy.bob Jan 13 '11 at 12:31
  • 2
    From a differrent angle, what on the list do you feel you can't automate? – Tyanna Jan 13 '11 at 12:42
  • Putting both dlls live and moving over SQL scripts at the same time (and executing on the server). – billy.bob Jan 13 '11 at 12:43
  • @m.edmondson. Take the hint. Please **update** the question with some specific information that we have to go on. Specifics matter. "etc." isn't very informative. We can make up all kinds of irrelevant things. Please give us a hint to focus on something useful you can use. – S.Lott Jan 13 '11 at 13:04
  • 1
    The question of how to automate a build isn't subjective, and should be asked on Stack Overflow. The question should also have more information on the tasks needed, to get a useful answer. – David Thornley Jan 13 '11 at 14:58
  • This STRONGLY depends on your environment –  Jan 13 '11 at 17:16
  • I agree with @David Thornley on this, it is a completely objective question once the OP provides sufficient details. – MIA Jan 13 '11 at 17:33
  • I have a feeling this would be closed on SO very quickly: "Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow..." – Chase Ries Mar 21 '14 at 20:32

6 Answers6

10

Make can automate the build process into one step. Make can do pretty much what ever you want. I am not sure why sapporo thinks that Make only applies to C/C++. You can use make to run any type of command. It is not even tied to programing though that is what it is typically used for.

Pemdas
  • 5,385
  • 3
  • 21
  • 41
  • 2
    make is one of those "swiss army knife" kind of tools; love working with it. Something else to point out where make would be useful is that if you are automating your build/process/etc, and one or more steps depend on another completing successfully, make will stop if that step fails, not allowing those other steps to proceed and possibly cause problems. – Will Jan 13 '11 at 14:09
  • 1
    Since many 'nix apps/systems are installed with './configure; make; make install' I think make also doubles up as an installation engine. If it can do that, I'm also sure it can solve the OP's quandry. – JBRWilkinson Jan 13 '11 at 17:52
  • Make, but the syntax is pretty obscure. To date I've encountered 2 alternatives: SCons (much easier than Make + makedepend) and a tool to automate the creation of the Makefile (proprietary). – Matthieu M. Jan 13 '11 at 18:08
  • @JbRWilkinson...like I said make can do pretty much whatever you want ;) – Pemdas Jan 13 '11 at 18:15
3

Depending on your environment, you may want to look at Make (C/C++), Ant/Maven (Java), Gradle (Groovy) - that's the ones I'm familiar with. Chances are high there's a popular solution for your environment.

sapporo
  • 131
  • 1
  • Its an ASP.NET / SQL environment – billy.bob Jan 13 '11 at 12:35
  • @m.edmondson - then http://cruisecontrol.sourceforge.net/ is probably your way to go – bobah Jan 13 '11 at 12:45
  • Another good continuous integration environment for ASP.NET is TeamCity. I've used by CruiseControl and TeamCity and I found TeamCity to be a bit easier to use and a bit more powerful. But that might no longer be the case. – RationalGeek Jan 13 '11 at 13:07
  • NANT is the .NET ANT variant which we've used well as a complement to Cruise Control which I wouldn't use to build code for deployment where you tend to want a few additional things included / tweaked / parameters set and changed and so on. That's what ANT/NANT are good at. – Jon Hopkins Jan 13 '11 at 17:22
  • I second @Jon Hopkinds suggestion - nant is a great match for your environment. – JBRWilkinson Jan 13 '11 at 17:53
  • @bobah: Isn't CI a step beyond getting a build process going? – JBRWilkinson Jan 13 '11 at 17:54
3

At work, we use FinalBuilder, which makes it easy to set up a script to automate the entire process: check out code, build everything, run tests, create deployment package, etc.

It's a very good tool, and it recently won the Dr. Dobbs Jolt Award for Change and Configuration Management tools.

Mason Wheeler
  • 82,151
  • 24
  • 234
  • 309
0

Sure there is a way to automate this. With tools like Chef, setting up a brand new freshly-installed server can be as easy as:

knife bootstrap ip.address -N aNameForTheServer -r "role[some functionality]"

In my case some steps executed by that single command are:

  • Install required libraries, programs and Python modules
  • Create new users with specified access privaleges
  • Create new databases, load required schema, set ownership and access rights
  • Download and stage project code and then write out configuration info
  • Bring everything into production mode by launching database servers, setting up cron jobs, etc.

I'm not sure how Chef will perform in your environment as Windows support is listed as "preliminary", but for UNIX-based system it's the bee's knees.

Puppet is a similar system that is a little older than chef and may offer better Windows support.

Sharpie
  • 912
  • 6
  • 9
0

It's straightforward with Maven in the Java world

mvn clean deploy

In our configuration, this does all the necessary building of the WAR file (pulling in the JAR dependencies as needed), the deployment to the dev web server and creation of canned test data on the dev database. Once that's in place Maven handles the comprehensive functional testing through SeleniumRC to verify the application works.

This single command gets the application fully deployed to the dev server cluster so it's readily available for other developers to immediately work with (assuming it passed the tests). It's unusual for a dev deployment to fail since developers have verified it works locally with mvn clean install.

The snapshot artifact (WAR) is then copied into the Maven repository for sharing with other developers (as per the standard Maven deploy behaviour).

OK, but you've only deployed a snapshot to dev, what about test and production?

The distribution to the test and (later) production servers is handled through the Maven release process which we like to handle manually to ensure that someone is watching for any suspicious output. Testers only work with released artifacts, not snapshots.

Once it's released then a simple build script is used to SFTP the WAR file to the test server cluster, again with someone watching the process to ensure nothing goes wrong.

Finally, after all the testers are happy the unchanged WAR file is SFTP'd up to the failover production server cluster, with someone keeping a close eye and an immediate rollback position in place in case of disaster.

Gary
  • 24,420
  • 9
  • 63
  • 108
0

I figured I could check that one off our Joel test so...

I made a build server in python automated it using pychron.

The code was synced with VSS from the command line, build with borland make (most IDEs'll create make files for you whether or not they call them that. Delphi used to pump out make files and call them .BPG files, now they're MSBuild XML files and you can use MSBuild) and the errors were put in an XML file which I just kept adding to.

So.. Just write a batch file and do these things.

  1. Synchronize Code from Source Control
  2. Delete dumb stuff (individual config files for projects) that you know will stop you from being able to build everything.
  3. Build everything (I'd build everything, make all brother).
  4. Log your errors and warning and stuff, but don't stop building. (If you're really smart you'll extract the name of the last person to check in the file that caused the build to break and send him a nastygram)
Peter Turner
  • 6,897
  • 1
  • 33
  • 57