Posts Tagged Build

Spawning a Process from Hudson

It took a little while to figure this out, and hence documenting here ...

Need is to restart JBoss once the artifacts are deployed. I have two different jobs, one for building and deploying artifacts (EAR, in this case) and the other one to restart the server. Former invokes the latter as a part of its post-build actions.

I've setup a build step in Hudson that executes a shell script which essentially invokes stop and start operations on the server. The server stops fine, but when I start the server in the background, server process gets killed once the Hudson process is finished. I've tried multiple ways of achieving this -- tried a couple of JBoss Maven plugins and tried Ant route too suspecting if that was an issue with my Shell script. But the real problem lies with the way Hudson deals with the spawned processes. This behavior is consistent with their design according to Hudson docs.

The suggested workaround for Unix systems is to use something like daemonize. That didn't work for me. Daemonize works fine but the process is still being killed by the Hudson.  [Side note: daemonize is a neat tool, glad that I stumbled on it. Need it for some other purposes].

So how was this resolved? Searching the bug tracker, found the exact issue that I mentioned here. The solution/workaround mentioned there works like a charm. Here is what it says --

set the environment variable BUILD_ID to something like 'dontKillMe' in the
process that should stay alive.

Hudson looks for that environment variable when cleaning up stray processes.

SetEnv plugin is already installed on my Hudson server, and setting BUILD_ID variable value worked! May be that Hudson could provide an option on the admin UI for the user to indicate not to kill the intentionally spawned processes.

Tags: ,

Graphical Representation Using Graphviz – Part 1

If you believe in the proverb - a picture is worth thousand words, then you would love this one. A few bloggers recently posted how Grand and Graphviz can be used for generating graphical views of the ANT dependencies. After a bit of research into how Grand achieved the task, I was inspired to do a similar thing, albeit on a different set of XML files (not on ANT scripts).In this post I will go over how these tools work together, and in the next part I will go over the details of creating a DOT file and generating the graphs to your liking.Before getting into the details, a quick summary of these tools below:

Grand

"Grand is a tool to create visual representation of ant target dependencies. It differs from tools like VizantAntGraph by a totally different approach, relying on the Ant API rather than parsing directly the XML files. This enables Grand to provide some nifty features such as the support of the ant 1.6.x tasks like import or subant".

Grand has a GUI, I haven't used it as I wanted to invoke this from ANT (or from command line).

Graphviz

"Graphviz is open source graph visualization software. It has several main graph layout programs. See the gallery for some sample layouts. It also has web and interactive graphical interfaces, and auxiliary tools, libraries, and language bindings."

"The Graphviz layout programs take descriptions of graphs in a simple text language, and make diagrams in several useful formats such as images and SVG for web pages, Postscript for inclusion in PDF or other documents; or display in an interactive graph browser. (Graphviz also supports GXL, an XML dialect.)"

Graph of ANT dependencies

For the demonstration purpose I'm using Spring Framework's build.xml.

Some obvious steps:

  1. Download Grand JAR
  2. Download and install Graphviz

Not so obvious ones:

  1. Create a typedef in your ANT build file
    <typedef resource="net/ggtools/grand/antlib.xml" classpath="lib/grand-1.8.jar" />
  2. Write an ANT target
    <target name="SpringFramework-BuildDiagram">   <grand output="docs/spring-f
    ramework.dot" buildfile="spring-framework-build.xml">
    
       <exec executable="dot" dir="docs">       <arg line="-Tpdf -Gsize=11.69,8.27 -Grotate=90 -o spring-framework.pdf spring-framework.dot"/>   </exec></target>

This is a two step process as described in the above target:

  • First step is to generate the dot file (note: this has got no relation with MS Word's dot template). DOT is a plain text description language of graphs. Provide an output path and what build file you need a diagram for.
  • Using that dot file graphviz generates the output graphs. Graphviz supports a wide range of output options. The above targets invoke dot and provides output type as PDF, provides the paper size to print on, and -Grotate value indicates the output to be rotated 90 degrees for landscape mode.

Here is a jpg output for Spring framework's build file --

Grand supports filters to remove any targets from the graph that you are not interested in. For example, if you are not interested in test-related targets and in isolated nodes (nodes that have no connections) the following ANT target achieves that functionality --

<target name="SpringFramework-BuildDiagram">   <grand output="docs/spring-framework.dot" buildfile="spring-framework-build.xml">        <filter name="removenode" node="clover.tests"/>       <filter name="removenode" node="clean.compile"/>       <filter name="isolatednode"/>    </grand>

   <exec executable="dot" dir="docs">       <arg line="-Tpdf -Gsize=11.69,8.27 -Grotate=90 -o spring-framework.pdf spring-framework.dot" />   </exec></target>

Resulting Graph --

spring-framework

Tags: ,

Good Bye to Beetlejuice, Back to CruiseControl/AntHill

For jamecs, we have tried Beetlejuice for the Continous Integration. True to what they claim, installation is a breeze. For Ross (my team-mate) it took only couple of minutes to install and a couple more to setup the system. We liked it initially but recently it is hogging the machine memory and severely impacting the server's performance. We will give them benefit of doubt at this point, as they're still in beta. Now back to the earlier plan, we're back to either CruiseControl or AntHill ..

Tags: