rblog

Create a blog post in Confluence using Groovy

Needed a way to publish a file containing a list of application versions installed in our WebSphere environment. What better to use than Groovy and XML-RPC for Atlassian Confluence. Tested on version 3.5


import groovy.net.xmlrpc.*

// ************** Set according to your environment ********
def SERVER = "http://<YOUR_SERVER_NAME>/rpc/xmlrpc"
def UID = "<UID>"
def PWD = "<PWD>"
def SPACEKEY = "<SPACEKEY>"
def BLOGTITLE = "<BLOGTITLE>"
def CONTENTTXT = "<TEXT WITH MACROS AND SUCH>"
// *******************************************************

println "Connect to server"
def c = new XMLRPCServerProxy(SERVER)

println "Login to server"
def token = c.confluence1.login(UID,PWD)

// Example found at http://confluence.atlassian.com/display/DISC/XML-RPC+Page+Updater+Example
println "Create blog and then save it"
def newBlogdata = [space:SPACEKEY,title:BLOGTITLE,content:CONTENTTXT]
c.confluence1.storeBlogEntry(token, newBlogdata)

// Clean up by logging out
println "Logout"
c.confluence1.logout(token)

Update:
In additon you would off course need to download the needed jar file, get it at http://groovy.codehaus.org/XMLRPC