Saturday 23 March 2013

Git clone not working in Jenkins

Poor Jenkins&Git integration...

When I was trying to setup some git jobs in Jenkins today, it turned out to be more tricky than I initially expected.
Upgrading to latest Jenkins 1.506 and Git Plugin 1.3.0, we were off to a bad start:
Command "/usr/bin/git clone --progress -o origin ssh://gitserver.company.com:22/project/one
 /path/to/jenkins/jobs/test/workspace" returned status code 128: Cloning into an existing
directory is not allowed.

After quite a lot of digging, I finally found the root-cause, solution and a work-around...

Solution

Upgrade Git to at least version 1.6.0.2.

Work-around

Downgrade Jenkin's "Git client Plugin" to version 1.0.2 (Download from here: https://updates.jenkins-ci.org/download/plugins/git-client/1.0.2/git-client.hpi)

Root-cause

"Cloning into an existing directory is only allowed if the directory is empty." only became reality in later versions of Git.
While Jenkin's "Git client Plugin" made a change (JENKINS-16873) in version 1.0.3 which relies on this feature, any installation with an older Git will fail to work.

Saturday 9 March 2013

How to use Node.js with WebLogic OSB

I recently came across a situation where there was a requirement to use WebLogic OSB configuration in a Node.js application. The information in question was the Endpoint URIs for all Business Services found in the OSB.
Since WebLogic removed "ServiceConfigurationMBean" from WLST in 11g, writing a Python script as you normally do was out of the question. Using Java was the only possibility at this stage, but it felt a bit much writing a new app just for a simple task like this.

This is when a college pointed me to https://github.com/nearinfinity/node-java which is a module to write native Java which is then executed inside your javascript using Node.js.

It turned out to be very straight forward and I added a sample JavaScript here: https://gist.github.com/dunse/5122258

In order to run the script, you will need Node.js, Java and some WebLogic libraries.
The WebLogic libraries been specified in the getbs.js file as:
java.classpath.push('configfwk-1.1.0.0.jar');
java.classpath.push('sb-kernel-impl-1.1.3.0.jar');
java.classpath.push('sb-kernel-api-3.0.jar');
java.classpath.push('sb-kernel-common-1.1.3.0.jar');
java.classpath.push('wlfullclient-10.3.0.jar');
java.classpath.push('standalone_client-11.1.1.jar');
Copy those files to the current working directory and update any version numbers as necessary.


Next, define your connection options:
var config = {
        admin_server: {
            "hostname": "z2esbadmin01.zst.optusnet.com.au",
            "port": 9001,
            "username": "weblogic",
            "password": "w3blogic"
        }
    };


And then run it:
node getbs.js

If all goes well, it will output something similar to this:
qwerty/business_services/qwerty_bs       =>       http://my.backend.server.com:8080/EndPoint/
...