Showing posts with label Build and Release. Show all posts
Showing posts with label Build and Release. Show all posts
on Wednesday, 30 May 2012
As I work through the book Continuous Delivery: Reliable Software Releases Through Build, Test, and Deployment Automation (Addison-Wesley Signature) I find myself highlighting sections that I feel are extremely useful and important. I dont claim to know everything, I've only been in this field for 2 years and only worked for 1 company. My experience is limited but this book has proven to be a valuable resource - there are bits i disagree with and I will go through those as I progress through the book.

Here's a section the author discusses. When a developer is ready to submit a piece of work:

  1. Before submitting any changes a developer should check to see if a build is currently in the "Successful" status. If not, a developer should assist in fixing a build before submitting new code.
  2. If the status is currently "Successful", a developer should rebase his/her personal workspace to this configuration.
  3. Build and test locally to ensure update doesn't break developers functionality.
  4. If Successful, check in new code.
  5. Allow CI to complete with new changes.
  6. If build fails, stop and fix on developers machine. Return to step 3.
  7. If build passes, continue to next work item.
on Saturday, 26 May 2012
I've just started reading Software Build Systems: Principles and Experience by Peter Smith PhD and one of the chapters discusses development tools and how to best manage them. This is only a small part of the book, but it's one of my favourites because it's easy to implement and the benefits are huge.


#1 Take Notes
I think this is one of the most important things to do when testing tools or running a proof of concept. It's so easy to get carried away with simply getting something to work that you actually forget the steps you took to get there. I would recommend getting yourself a little notepad and jotting down some bullet points - this can be fleshed out later. I personally like to open a text editor like notepad and put everything in there. Mainly because its easier to copy and paste file paths than jott them down on paper.

#2 Use Version Control for Source Control
This rule relates to tools you use that need to be compiled for different targets. You shouldn't always trust that your files will be available online (if thats your source). By keeping your tools in version control you can always rest assured that if anything catastrophic ever happens to your source, or even if they just remove them, you will always have them.

#3 Periodically Upgrage Tools
I'm going to aproach this rule quite differently to the book. I think there has to be a happy medium here; you need to upgrade your tools regularly to stay inside support, but also do it in a controlled manner and not as soon as a new release is made available.

A short time ago I was caught out upgrading one of the plugins on our continuous integration tool. To cut a long story short the latest version of one plugin was faulty and braught down our whole CI system. At the time I done a big bang upgrade of the plugins the CI used and it was a nightmare to track down the root cause and rectify. The moral of this is time the upgrades well, give new releases time for error's to manifest, but upgrade so you get new features and bugfixes.

#4 Version Binaries
I think this should be an extension of rule #2 because the reasons are pretty much the same. Just to reiterate though, keep the tools you use versioned and in your repository so that they are always available!
on Saturday, 5 May 2012
I found this on the net a long time ago and thought I would share. Basically, it parses a log file and extracts the errors.

 <target name="build">
  
   <echo message="Add foo bar baz"/>
  
        <exec executable="${db.sqlplus}">
  
   </exec>
  
   <echo message="Load x y z"/>
  
        <exec executable="${db.sqlplus}" dir="foobar">
  
   </exec>
  
   <!--Check the log files here-->
  
           <check-log-file fileToCheck="${output.log.1}"/>
  
           <check-log-file fileToCheck="${output.log.2}"/>
  
   <antcall target="fail-if-error"/>
  
 </target>
  
 <!--=================================================================================
  
   Check the file named in the property file.to.check to see if there are errors.
  
   The way this works is to find all lines containing the text "ERROR" and put
  
   them into a separate file. Then it checks to see if this file has non-zero
  
   length. If so, then there are errors, and it sets the property errors.found.
  
   Then it calls the send-email target, which doesn't execute if the errors.found
  
   property isn't set.
  
 -->
  
 <macrodef name="check-log-file">
  
   <attribute name="file.to.check"/>
  
   <attribute name="file.errorcount" default="@{file.to.check}.errorcount" description="The file to hold the error lines"/>
  
   <sequential>
  
     <copy file="@{file.to.check}" tofile="@{file.errorcount}">
  
       <filterchain>
  
         <linecontains>
  
           <contains value="ERROR"/>
  
         </linecontains>
  
       </filterchain>
  
     </copy>
  
     <condition property="errors.found" value="true">
  
       <length file="@{file.errorcount}" when="gt" length="0"/>
  
     </condition>
  
     <antcall target="check-log-file-send-email">
  
       <param name="file.to.check"  value="@{file.to.check}"/>
  
     </antcall>
  
   </sequential>
  
 </macrodef>
  
 <!--=================================================================================
  
   If there are any errors, send an email to let someone know
  
 -->
  
 <target name="check-log-file-send-email" if="errors.found" description="Sends an email out if error detected">
  
   <resourcecount property="error.count">
  
     <tokens><!-- default tokenizer is a line tokenizer -->
  
       <file file="${file.to.check}.errorcount"/>
  
     </tokens>
  
   </resourcecount>
  
   <echo message="Database build (${e1.codeline} - ${error.count} errors found..."/>
  
   <antcall target="mail">
  
     <param name="from-address" value="build"/>
  
     <param name="to-list"    value="myemail"/>
  
     <param name="subject"    value="Automated database build error report for ${db.host}"/>
  
     <param name="message"    value="See attached log file, ${error.count} error(s) found..."/>
  
     <param name="attach"    value="${file.to.check}"/>
  
   </antcall>
  
 </target>
  
 <!--=================================================================================
  
   Fails the database build if errors were detected.
  
 -->
  
 <target name="fail-if-error" if="errors.found">
  
   <echo message="Errors found - setting database fail flag..."/>
  
   <fail message="Errors detected during ${codeline} database build. Check logs."/>
  
 </target>  
on Friday, 4 May 2012
Just yesterday I was offered a new job with a relative large insurance firm in the UK. My role will be to bring the build management team up to scratch and implement a framework from the ground up. This got me thinking... what are the tools and good practices I cant live without?


Build & Release Website

Every software development outfit should have one of these! Some of the information you would store is:

  • Functional Release Notes
  • Technical Release Notes
  • Continuous Integration Results (Link to tools)
  • Project Documentation (Javadocs or LXR)
  • Runtime Logs
  • Deployed Applications (A list of environments and their current deployments)
  • Application Metrics
  • Third Party Documentation (Tools, Libraries)
  • Misc Documents

This should be maintained by the Build & Release team and should be automated. Our systems are configured to deploy the documentation once its been created.

Build & Release Calendar

Another tool no serious software company should be without. The projects that you support should be able to see your workload and manage requests accordingly. Also, if you need to justify where you're spending your time this acts as a great record for the finance department or Project Managers. There are free calendars available and tools like Jenkins also provide work well with Google Calendar.

Build Framework

No sh!t, really?! It doesn't matter what tools you use, but you should be able to build, package, run unit tests and deploy at very least. The aim here is to produce a framework that can be used with very little configuration and flexible enough to use with new projects. Some of the "powers-to-be" at my office have been trying to get us to switch to Maven for a while now. The argument that we're forced to use a single framework is a fair one, but my counter argument is that our Ant framework is so well made that we wouldn't be achieving anything by switching. Ant is a highly configurable tool but takes a lot to get up and running, however Maven is not so flexible but is much easier to use "out of the box".

Continuous Integration

CI is often considered something only used by large scale projects. This doesn't have to be the case. Even if you're a small operation with only a handful of developers it makes sense to offload the task of compiling your source and running a few simple tests. To put this into context, if you have 5 developers, a build takes 1 hour and each developer builds at least once a day, thats 25 hours wasted on builds a week. At a very generous rate of £15 per hour thats £375 a week and £1500 a month wasted in consumed resources for builds. Thats the build server bought and paid for!!

on Thursday, 3 May 2012


When we make any changes to our databases we like to restart the application servers to refresh the datasources. Some of our development environments are run as Windows services and so it would be nice to restart them remotely from the build machines. Here's how with Ant:

I hope you can see in this snippet that the code runs 2 tasks - Stop and Start. You can break down the code if you just want a Start or Stop only script.
on Monday, 23 April 2012
Something simple, but very effective!

I want you to do something for me; at the top of the browser you’re reading this on there should be a help button (unless you’re on a mobile device). Click it, then click the about option. You should be presented with something similar to this:



If the application you or your company is developing doesn’t have this feature then you need to give yourself a slap on the wrist and ask yourself, WHY? As a release engineer we’re often expected to know exactly what’s in every environment at all times. If you’re a small organisation with only a few projects and deliveries then this is sometimes possible, but even then what happens if you go on holiday and someone else covers for you??

If you’re using Ant I would advise writing a small task that will pull a few basic parameters from your build machine. Some useful properties to gather are the following:

Username
Build Machine

Date
Time
Build Number

Here’s the Ant target I use. It includes some ClearCase stuff (the source tool we use) but I thought I would leave it in for information.


 <target name="buildinfo" description="Record build metadata">
  
 <echo message="${line.separator}" file="${build.props.file}" append="true"/>
  
 <echo message="buildby=${env.USERNAME}${line.separator}" file="${build.props.file}" append="true"/>
  
 <echo message="host=${env.COMPUTERNAME}${line.separator}" file="${build.props.file}" append="true"/>
  
 <echo message="builddate=${build.time}${line.separator}" file="${build.props.file}" append="true"/>
  
 <echo message="buildview=${cc.view}${line.separator}" file="${build.props.file}" append="true"/>
  
 <echo message="buildstream=${cc.stream}${line.separator}" file="${build.props.file}" append="true"/>
  
 <echo message="buildproject=${cc.project}${line.separator}" file="${build.props.file}" append="true"/>
  
 <echo message="foundationbaseline=${cc.found-baselines}${line.separator}" file="${build.props.file}" append="true"/>
  
 <echo message="recommendedbaseline=${cc.rec-baseline}${line.separator}" file="${build.props.file}" append="true"/>
  
 <echo message="Projrecommendedbaseline=${cc.rec-bline-stream}${line.separator}" file="${build.props.file}" append="true"/>
  
 <echo message="currentbaselines=${cc.current-baselines}${line.separator}" file="${build.props.file}" append="true"/>
  
 </target>
  


Write some code to get this to display in your app then its job done!

As I mentioned in my previous post, my favourite email plugin is the Email-ext plugin . Here's the configurations I use for notifying people when build conditions are met.

UNSTABLE


$PROJECT_DEFAULT_CONTENT

Failing tests:
${FAILED_TESTS}

When a build becomes unstable it's telling you a build has been succesful, but some of your JUnit tests have failed. It is a good idea to let the whole team know this has happened and send them the list of failed tests.

FAILURE

$PROJECT_DEFAULT_CONTENT
Build started by ${CAUSE}
Changes since last build:
${CHANGES}

A failed build is more serious than an unstable build because someone has submitted code that is erraneous and could impact everyone else who is working on the CI stream. For this reason we need to monitor what has been submitted since the last working build and why the build was started.

STILL FAILING

$PROJECT_DEFAULT_CONTENT
Build started by ${CAUSE}
Changes since last build:
${CHANGES_SINCE_LAST_SUCCESS}

This is the same as a failing build, but instead of notifying everyone, we now only email submitters. The reason for this is because they're adding to a broken environment, hopefully this will encourage the developer to chase down the error and fix it so that they can check their own build status.

FIXED

$PROJECT_DEFAULT_CONTENT


STILL UNSTABLE

$PROJECT_DEFAULT_CONTENT
Failing tests:
${FAILED_TESTS}

This is the same as still failing but instead we report the failed tests to the submitter in the hope they will fix the issue. If not then you need to turn Judge Dredd on them!
on Thursday, 19 April 2012


Audit TrailKeeps a log of who performed particular Jenkins operations, such as configuring jobs.
Wiki
Download

A very simple plugin that logs all actions performed in Jenkins. If you suspect someone is messing with your hard work then check the log and find out. The log also tells how each build was started which is also another good bit of information.


ClaimAllow broken build claiming.
Wiki
Download

I’ve often experimented with project configurations which have broken the builds which have then sent an email notifying the whole team. It’s a poor use of resources if you have developers looking for faults in the build when you know you are the cause. This is where the plugin comes in. By claiming a build you’re ultimately telling the team “I broke the build and I’m working on fixing it”, this can save masses of developers time by not having them all looking for the same problem.

Console Columnprovides a fast-path console link available for views.
Wiki
Download

Very simple but effective plugin that adds a link to one or more (Last Console, last failed, last stable, last successful or last unsuccessful) consoles. I’ve created an “All Projects” view and added a column to link all last consoles.


 
 
 


Description Setter - sets the description for each build, based upon a RegEx test of the build log file.
Wiki
Download

If like me you have your build output lots of information in your logs you can look for this information and tie it to a build. I use Rational ClearCase for my source control and when I create a build I always pull down information about the baseline I’m using. All I need to do is set up a regular expression for this information then the plugin sets this information next to build.


Disk Usagerecord individual project disk usage.
Wiki
Download

Storage is cheap these days but you should still keep tabs on how much your CI is using. A great plugin for this is the Disk Usage plugin. It does exactly what it says on the tin so I won’t keep on. There is one caveat, and that is at the time of writing if you have several jobs sharing the same workspace it will think they are separate and add them all together. I have 3 jobs but only a single workspace (3gb) unfortunately this plugin does a 3x3 calculation and reports that I’m using 9gb - obviously that isn’t correct.


Email-extreplacement for Jenkins email publisher.
Wiki
Download

The email publisher built into Jenkins is good, but this is so much better. With this tool you can specify what information is emailed, to whom and for what condition.
The plugin works around the concept of triggers. Triggers are conditions that are met and warrant some action. Let’s say a build fails, you may want the whole team to know so that it can be resolved. However, if a developer submits a failing test you may not want to send everyone an email, just the culprit. The plugin allows you to do all of this as well as customise the emails you send. This is a great tool that we can’t live without now.


Job Config Historysaves copies of all job and system configurations. Wiki
Download

Have you ever changed the configuration of a build, it’s started failing but you can’t remember what you changed? Well, that’s exactly what this plugin solves. If you go into one of your jobs you will notice an icon on the left “Job Config History”.








If you click this option you will be presented with a page full of change history. You can compare entries and explore the XML for the faulty change. Note – the plugin doesn’t show you where in the GUI you have made the change so you will need to understand how XML works to find that yourself.




Hudson Tray Applicationprovides a Tray application that monitors this (and other) Hudson servers.
Wiki
This is a great little plugin that installs a simple app in the system tray that you can use to monitor the jobs on your CI server. The app means that you no longer have to log in via the browser to get an update on project statuses and you can even launch builds from the app itself.


Monitoring - Hudson/Jenkins' monitoring with JavaMelody.
Wiki
Download

Statistics make the world go round, right? It’s important to know if our servers are handling the strain of building our projects continuously. I strongly advise firing off a number of builds and seeing how well your server is performing. I’ve learnt a lot from just playing around and I’ve reached a nice performance from the build machines without risking out of memory errors.
on Monday, 3 May 2010
So, hello everyone (if everyone is anyone!), this is my first post so I thought I would give you a little information about myself - I'm a 24 year old male from Newport, South Wales, UK.

I currently work for the Office for National Statistics as a Build and Release Engineer. My job involves gathering all code from developers and creating a package that can be deployed to our application servers for the business area staff to do their bit; this generally involves collating data, analysing it then releasing the new information to the public. A few of the higher profile projects would include the 2010 Census, National Accounts and many others. Some of the software that I use on a regular basis is IBM's Rational suite which handles our source control, Apache Ant and Maven for the build framework along with Oracle Database Management System (DBMS) for all that crazy database stuff. I've been in this job for 6 weeks now and I'm enjoying it tremendously, it's my first job since graduating and I'm always learning something new.

I graduated in June 2009 becoming a BSc Computer Games Development, however, since graduating I haven't done much in the way of games programming which upsets me a little; I have however got myself a copy of the latest “Game Coding Complete” by Mike McShaffry which I do plan to read through and start programming examples from. As I work my way through each example I will be sure to post my experiences and error's – as anyone in programming will now are all too unavoidable.
Well, thanks for reading and I hope you come back for more!