Showing posts with label methodology. Show all posts
Showing posts with label methodology. Show all posts

Tuesday, December 6, 2011

Passing upstream parameters to downstream builds in Jenkins

Jenkins has cool Pipeline plugin, which helps to create build pipelines, that for example, can organize and visualize deployment process. Plugin is very cool and looks great, but lacks few basic features, like passing generated parameters or variables from upstream builds to downstream.
For example, I wanted to pass SVN revision number into downstream builds.
Fortunately it is easy to do it with little hacking. Here is what I did.
  1. Add Groovy plugin.
  2. Add new build step Execute system Groovy script, now it is possible to hook into Jenkins internals.
  3. Then just add Groovy script there:
import hudson.model.*
def thr = Thread.currentThread()
def build = thr?.executable
build.addAction(new ParametersAction(new StringParameterValue('SVN_UPSTREAM', build.getEnvVars()['SVN_REVISION'])))


What this script does it just creates new parameter and adds SVN_REVISION from environment variables there. And pipeline can pass parameters with this mechanism to downstream builds (all of them).
Easy!

Tuesday, March 16, 2010

Code bubbles IDE

There is  buzz in java world about new IDE concept. Idea is that it combines contexts and helps to keep all related files and information around tasks and ideas, but not around files and classes like traditional IDE.
Generally it is the same Mylyn idea, maybe better implementation, but should be tried.
Interesting presentation anyway.

Saturday, March 6, 2010

BDD - Behavior Driven Development

New interesting methodology that combines automatic testing and requirements specification. I love the concept for some time with Fitnesse, but here is another formalized methodology and buzzword. More about it here.

Method chaining issue

I met one interesting issue with method chaining today.
Method chaining is popular thing now, introduced by Martin Fowler and you probably seen it somewhere already, you can read about it here.
Generaly it looks like:

new HardDrive().capacity(150).external().speed(7200);

contrary to classic Java style

HardDrive hd = new HardDrive();
hd.setCapacity(150);
hd.setExternal(true);
hd.setSpeed(7200);


Today I found one funny issue with it. I got bug in this code:


parent.add(new Node()
.setName(name)
.setValue(value)
.setParent(parent))
.setId(id)


Of course, bug is trivial and easily found with debug. But what is bad with this bug, syntax is correct, so it is not discovered by IDE and it is not easily visible. For example, compare it to old style:


Node node = new Node();
node.setName(name);
node.setValue(value);
node.setParent(parent);
parent.setId(id);
parent.add(node);


Another minor bonus is that it is also easier to debug.