Passing Hudson BUILD_NUMBER to Sonar Plugin

Sonar is a great source code analysis tool that integrates through its plugin neatly into the Hudson continuous integration server. One major feature of Sonar is the module called “Time machine” where you can review the progress of the quality metrics for your project over time. However, to see this progress, it is necessary to tag the version of the Sonar run dynamically, otherwise, the new run “overwrites” the previous results. Sonar does not really discard the old results, but to fetch the older outcomes in the Time machine view is quite tedious.

So, what you need to do is really simple:

  1. Pass the BUILD_NUMBER to the Maven call in the field “Additional properties”
  2. Have the Sonar Plugin insert a variable for replacement in the generated POM file

In my example the replacement variable is called “version” but you can name it as you want.

Pass a variable Version Number to Hudson Sonar Plugin
Pass a variable Version Number to Hudson Sonar Plugin

With the shown configuration Sonar will store the results under “hudson-##” where ## is the current iteration of the Hudson build cycle. Of course it is also possible to pass other information, like the BUILD_ID or JOB_NAME. A listing of available Hudson environment variables can be found here.

Andreas

Save a Sharepoint Password in Firefox

Using a Sharepoint site is for Firefox users can very annoying as the Website, for what reason whatsoever, does not allow the Web browser to store the password. Some other sites also disallow for security reasons to store the password in the browser.

Sometimes, the trouble even doubles as the user can not change his/her Sharepoint password and always has to lookup the cryptic generated password.

However, there is a solution for allowing Firefox storing the password available:

  1. Go to the Login page of the Sharepoint Website
  2. Enter you username and password
  3. Copy the JavaScript code below into the Firefox Location bar
  4. Hit Enter and click on sign in
  5. Voilà, Firefox asks you if you like to save the password.

Copy this one into the location bar as it is written without any newlines:

javascript:(function(){var ca,cea,cs,df,dfe,i,j,x,y;function n(i,what){return i+" "+what+((i==1)?"":"s")}ca=cea=cs=0;df=document.forms;for(i=0;i<df.length;++i){x=df[i];dfe=x.elements;if(x.onsubmit){x.onsubmit="";++cs;}if(x.attributes["autocomplete"]){x.attributes["autocomplete"].value="on";++ca;}for(j=0;j<dfe.length;++j){y=dfe[j];if(y.attributes["autocomplete"]){y.attributes["autocomplete"].value="on";++cea;}}}alert("Removed autocomplete=off from "+n(ca,"form")+" and from "+n(cea,"form element")+", and removed onsubmit from "+n(cs,"form")+". After you type your password and submit the form, the browser will offer to remember your password.")})();

A more readable form of the JavaScript:

javascript:(
  function()
  {
    var ca,cea,cs,df,dfe,i,j,x,y;
    function n(i,what)
    {
      return i+" "+what+((i==1)"":"s")
    }
 
    ca=cea=cs=0;
    df=document.forms;
    for(i=0;i<df.length;++i)
    {
      x=df[i];
      dfe=x.elements;
      if(x.onsubmit)
      {
        x.onsubmit="";++cs;
      }
      if(x.attributes["autocomplete"])
      {
        x.attributes["autocomplete"].value="on";
        ++ca;
      }
 
      for(j=0;j<dfe.length;++j)
      {
        y=dfe[j];
        if(y.attributes["autocomplete"])
        {
           y.attributes["autocomplete"].value="on";++cea;
        }
      }
    }
    alert("Removed autocomplete=off from "+n(ca,"form")+" and from "+n(cea,"form element")+", and removed onsubmit from "+n(cs,"form")+". 
    After you type your password and submit the form, the browser will offer to remember your password.")
  })();

The script simply removes the HTML attribute “autocomplete=off” and has to be executed only once. You can check now if your password has been stored in the Firefox settings.

One minor issue remains: As the next time you visit the login page, the autocomplete attributes are active again, you must enter your complete login name, but this is quite easy to remember and the password will be automatically inserted by Firefox.

Reference: Force Firefox to Offer to Save …

HTH,

Andreas