Class VersionServlet

java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
com.randomnoun.common.servlet.VersionServlet
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class VersionServlet extends javax.servlet.http.HttpServlet
Reads the contents of the build.properties file in the current application and sends it to the browser in a variety of forms. Probably JSON for starters.

The properties file must be located on the classpath at the location "/build.properties".

For this to work, the application needs to have been built through maven (and possibly bamboo), and there should be a build.properties file in the application being created, with the contents:

  bamboo.buildKey=${bambooBuildKey}
        bamboo.buildNumber=${bambooBuildNumber}
        bamboo.buildPlanName=${bambooBuildPlanName}
        bamboo.buildTimeStamp=${bambooBuildTimeStamp}
        bamboo.buildForceCleanCheckout=${bambooForceCleanCheckout}
        bamboo.custom.cvs.last.update.time=${bambooCustomCvsLastUpdateTime}
        bamboo.custom.cvs.last.update.time.label=${bambooCustomCvsLastUpdateTimeLabel}
        
        maven.pom.name=${pom.name}
    maven.pom.version=${pom.version}
    maven.pom.groupId=${pom.groupId}
    maven.pom.artifactId=${pom.artifactId}
   
and the bamboo plan should have the following in the bamboo plan's stage's job's task's maven goal specification:
  "-DbambooBuildKey=${bamboo.buildKey}" 
    "-DbambooBuildNumber=${bamboo.buildNumber}" 
    "-DbambooBuildPlanName=${bamboo.buildPlanName}" 
    "-DbambooBuildTimeStamp=${bamboo.buildTimeStamp}" 
    "-DbambooBuildForceCleanCheckout=${bamboo.buildForceCleanCheckout}" 
    "-DbambooCustomCvsLastUpdateTime=${bamboo.custom.cvs.last.update.time}" 
    "-DbambooCustomCvsLastUpdateTimeLabel=${bamboo.custom.cvs.last.update.time.label}" 
    -DuniqueVersion=false 
 

This script will also look for a build.properties file in /etc/build.properties; this should exist on docker containers built by bamboo. If this exists, it is also included in the JSON output under the "/etc/build.properties" key.

Author:
knoxg
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.apache.log4j.Logger
    Logger for this class
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
    See class documentation
    protected void
    doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
    Post method; just defers to get

    Methods inherited from class javax.servlet.http.HttpServlet

    doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service

    Methods inherited from class javax.servlet.GenericServlet

    destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • logger

      public static final org.apache.log4j.Logger logger
      Logger for this class
  • Constructor Details

  • Method Details

    • doPost

      protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
      Post method; just defers to get
      Overrides:
      doPost in class javax.servlet.http.HttpServlet
      Throws:
      javax.servlet.ServletException
      IOException
      See Also:
      • HttpServlet.doPost(HttpServletRequest request, HttpServletResponse response)
    • doGet

      protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
      See class documentation
      Overrides:
      doGet in class javax.servlet.http.HttpServlet
      Throws:
      javax.servlet.ServletException
      IOException
      See Also:
      • HttpServlet.doGet(HttpServletRequest request, HttpServletResponse response)