net.sourceforge.cruisecontrol.publishers
Class WeblogPublisher

java.lang.Object
  extended bynet.sourceforge.cruisecontrol.publishers.WeblogPublisher
All Implemented Interfaces:
Publisher, java.io.Serializable

public class WeblogPublisher
extends java.lang.Object
implements Publisher

Used to publish a blog entry based on the build report using the Blogger API, MetaWeblog API or the LiveJournal API.

Here's a sample of the publisher element to put into your config.xml:

 <weblog blogurl="http://yourblogserver:port/blog/xmlrpc"
         api="metaweblog"
         blogid="yourblog"
         username="user1"
         password="secret"
         category="cruisecontrol"
         reportsuccess="fixes"
         subjectprefix="[CC]"
         buildresultsurl="http://yourbuildserver:port/cc/buildresults"
         logdir="/var/cruisecontrol/logs/YourProject"
         xsldir="/opt/cruisecontrol/reporting/jsp/xsl"
         css="/opt/cruisecontrol/reporting/jsp/css/cruisecontrol.css"
 />
 

And you also need to register the 'weblog' task with the following entry if you're using this task with an older version of CruiseControl which doesn't have the WeblogPublisher registered by default.

 <project name="foo">
      <plugin name="weblog"
          classname="net.sourceforge.cruisecontrol.publishers.WeblogPublisher"/>
      ...
 </project>
 

Author:
Lasse Koskela
See Also:
Serialized Form

Nested Class Summary
static class WeblogPublisher.BloggerApiClient
          A BloggingApi implementation for the Blogger API.
static class WeblogPublisher.LiveJournalApiClient
          A BloggingApi implementation for the LiveJournal API.
static class WeblogPublisher.MetaWeblogApiClient
          A BloggingApi implementation for the MetaWeblogAPI.
 
Constructor Summary
WeblogPublisher()
           
 
Method Summary
 net.sourceforge.cruisecontrol.publishers.WeblogPublisher.BloggingApi getBloggingApiImplementation(java.lang.String apiName)
          Selects a BloggingApi implementation based on a user-friendly name.
protected  java.lang.String[] getXslFileNames()
          Provided as an alternative to setXSLFileNames for changing the list of files to use.
 void postBlogEntry(java.lang.String subject, java.lang.String content)
          Posts the build results to the blog.
 void publish(org.jdom.Element cruisecontrolLog)
          Implementing the Publisher interface.
 void setApi(java.lang.String api)
          The API used for posting to your blog.
 void setBlogId(java.lang.String blogId)
          The "blog ID" for the blog you're posting to.
 void setBlogUrl(java.lang.String blogUrl)
          The URL where your blog's remote API is running at.
 void setBuildResultsURL(java.lang.String url)
          The base build results URL where your CruiseControl reporting application is running.
 void setCategory(java.lang.String category)
          The category to set for the blog entry.
 void setCSS(java.lang.String cssFilename)
          Path to cruisecontrol.css.
 void setLogDir(java.lang.String directory)
          Path to the log file as set in the log element of the configuration xml file.
 void setPassword(java.lang.String password)
          The password to use for authentication.
 void setReportSuccess(java.lang.String reportSuccess)
          The rule for posting a blog entry for successful builds.
 void setSpamWhileBroken(boolean spamWhileBroken)
          The rule for posting a blog entry for each subsequent failed build.
 void setSubjectPrefix(java.lang.String prefix)
          The prefix to be used before the title of the blog entry.
 void setUsername(java.lang.String username)
          The username to use for authentication.
 void setXSLDir(java.lang.String xslDirectory)
          Directory where xsl files are located.
 void setXSLFile(java.lang.String fullPathToXslFile)
          If xslFile is set then both xslDir and css are ignored.
protected  void setXSLFileNames(java.lang.String[] fileNames)
          Method to override the default list of file names that will be looked for in the directory specified by xslDir.
 void validate()
          Called after the configuration is read to make sure that all the mandatory parameters were specified..
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WeblogPublisher

public WeblogPublisher()
Method Detail

setXSLFile

public void setXSLFile(java.lang.String fullPathToXslFile)
If xslFile is set then both xslDir and css are ignored. Specified xslFile must take care of entire document -- html open/close, body tags, styles, etc.


setXSLDir

public void setXSLDir(java.lang.String xslDirectory)
Directory where xsl files are located.


setXSLFileNames

protected void setXSLFileNames(java.lang.String[] fileNames)
Method to override the default list of file names that will be looked for in the directory specified by xslDir. By default these are the standard CruseControl xsl files:
I expect this to be used by a derived class to allow someone to change the order of xsl files or to add/remove one to/from the list or a combination.

Parameters:
fileNames -

getXslFileNames

protected java.lang.String[] getXslFileNames()
Provided as an alternative to setXSLFileNames for changing the list of files to use.

Returns:
xsl files to use in generating the email

setCSS

public void setCSS(java.lang.String cssFilename)
Path to cruisecontrol.css. Only used with xslDir, not xslFile.


setLogDir

public void setLogDir(java.lang.String directory)
Path to the log file as set in the log element of the configuration xml file.


setApi

public void setApi(java.lang.String api)
The API used for posting to your blog. Currently, acceptable values are blogger,metaweblog and livejournal.


setBlogId

public void setBlogId(java.lang.String blogId)
The "blog ID" for the blog you're posting to. The value depends on your particular weblog product.


setBlogUrl

public void setBlogUrl(java.lang.String blogUrl)
The URL where your blog's remote API is running at. For example, the value could look like http://www.yoursite.com/blog/xmlrpc or http://www.livejournal.com/interface/xmlrpc.


setUsername

public void setUsername(java.lang.String username)
The username to use for authentication.


setPassword

public void setPassword(java.lang.String password)
The password to use for authentication.


setCategory

public void setCategory(java.lang.String category)
The category to set for the blog entry. When using the MetaWeblogAPI, you can also use a comma-separated list of several categories.


setSubjectPrefix

public void setSubjectPrefix(java.lang.String prefix)
The prefix to be used before the title of the blog entry. If null, no prefix will be used.


setBuildResultsURL

public void setBuildResultsURL(java.lang.String url)
The base build results URL where your CruiseControl reporting application is running. For example, http://buildserver:8080/cc/myproject.


setReportSuccess

public void setReportSuccess(java.lang.String reportSuccess)
The rule for posting a blog entry for successful builds. Accepted values are never,always and fixes.


setSpamWhileBroken

public void setSpamWhileBroken(boolean spamWhileBroken)
The rule for posting a blog entry for each subsequent failed build. Accepted values are true and false.


publish

public void publish(org.jdom.Element cruisecontrolLog)
Implementing the Publisher interface.

Specified by:
publish in interface Publisher
Parameters:
cruisecontrolLog - The build results XML

getBloggingApiImplementation

public net.sourceforge.cruisecontrol.publishers.WeblogPublisher.BloggingApi getBloggingApiImplementation(java.lang.String apiName)
                                                                                                  throws CruiseControlException
Selects a BloggingApi implementation based on a user-friendly name.

Parameters:
apiName - The name of the blogging API to use. One of blogger, metaweblog or livejournal.
Returns:
The BloggingApi implementation or null if no matching implementation was found.
Throws:
CruiseControlException

postBlogEntry

public void postBlogEntry(java.lang.String subject,
                          java.lang.String content)
Posts the build results to the blog.

Parameters:
subject - The subject for the blog entry.
content - The content for the blog entry.

validate

public void validate()
              throws CruiseControlException
Called after the configuration is read to make sure that all the mandatory parameters were specified..

Specified by:
validate in interface Publisher
Throws:
CruiseControlException - if there was a configuration error.