From 4ec8fadf39345998a7691b9ed5624bfe6be9f087 Mon Sep 17 00:00:00 2001 From: kaloyane <kaloyane> Date: Wed, 13 Apr 2011 19:04:34 +0000 Subject: [PATCH] added: script that 1) auto uploads sprint binaries to the "Sprint Releases" page in Confluence 2) generates Confluence text to publish on the "Sprint Releases" page SVN: 20893 --- .../bash/upload-sprint-to-confluence.py | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100755 openbis_all/source/bash/upload-sprint-to-confluence.py diff --git a/openbis_all/source/bash/upload-sprint-to-confluence.py b/openbis_all/source/bash/upload-sprint-to-confluence.py new file mode 100755 index 00000000000..5fc407038ce --- /dev/null +++ b/openbis_all/source/bash/upload-sprint-to-confluence.py @@ -0,0 +1,99 @@ +#!/usr/bin/python + +from __future__ import with_statement +from datetime import date +import sys, string, xmlrpclib, re, os, getpass + +DOWNLOAD_FOLDER="./tmp/" +confluenceToken = None +confluenceServer = xmlrpclib.ServerProxy('https://wiki-bsse.ethz.ch:8443/rpc/xmlrpc') +wikiText = "" + + +def printWiki(text=""): + global wikiText + wikiText += text + wikiText += "\n" + +def logIntoConfluence(): + global confluenceToken + user = getpass.getuser() + print "Please speficy Confluence password for user ", user + password = getpass.getpass() + confluenceToken = confluenceServer.confluence1.login(user, password) + if confluenceToken is None: + exit("Could not login page " + spacekey + ":" + pagetitle) + + +def uploadReleaseBinaryToConfluence(filename): + # ugly, but I don't want to spend more time here + filepath = DOWNLOAD_FOLDER + "/" + filename + with open(filepath, 'rb') as f: + data = f.read(); # slurp all the data + + spacekey="bis" + pagetitle="Sprint Releases" + + if confluenceToken is None: + logIntoConfluence() + + page = confluenceServer.confluence1.getPage(confluenceToken, spacekey, pagetitle) + if page is None: + exit("Could not find page " + spacekey + ":" + pagetitle) + + attachment = {} + attachment['fileName'] = os.path.basename(filename) + attachment['contentType'] = 'application/zip' + + print "Uploading {0} to confluence......".format(filename) + confluenceServer.confluence1.addAttachment(confluenceToken, page['id'], attachment, xmlrpclib.Binary(data)) + +def fetchBinaries(version): + print "Fetching {0} binaries from server ...".format(version) + os.system("mkdir -p " + DOWNLOAD_FOLDER) + os.system("rm {0}/*.zip".format(DOWNLOAD_FOLDER)) + os.system("scp sprint:~/fileserver/sprint_builds/openBIS/*-{0}*/*.zip {1}".format(version, DOWNLOAD_FOLDER)) + +def printVersion(version): + today = date.today().strftime("%d %B %Y") + printWiki("h2. Version {0} ({1})".format(version, today)) + +def processFile(linkName, filePattern, version): + fileName = findFile(filePattern + "-" + version) + uploadReleaseBinaryToConfluence(fileName) + printWiki("* [{0}|^{1}] ".format(linkName, fileName)) + +def uploadToConfluenceAndPrintPageText(version): + printVersion(version) + printWiki() + printWiki("h5. openBIS Generic Framework") + printWiki() + processFile("Application Server (AS)", "openBIS-server", version) + processFile("Data Store Server (DSS)", "datastore_server", version) + processFile("DSS Client", "dss_client", version) + printWiki("* [Documentation|^CISDDoc-{0}.html.zip]".format(version)) + printWiki() + printWiki('h5. openBIS for High Content Screening') + printWiki() + processFile("Application Server (AS)", "openBIS-server-screening", version) + processFile("Data Store Server (DSS)", "datastore_server-screening", version) + processFile("API", "screening-api", version) + +def findFile(filePattern): + for file in os.listdir(DOWNLOAD_FOLDER): + if file.startswith(filePattern): + return file + +if __name__ == '__main__': + if len(sys.argv) < 2: + exit(""" +Usage: {0} <SPRINT-NUMBER> +Example command: {0} S104 + """.format(sys.argv[0])) + version=sys.argv[1] + fetchBinaries(version) + uploadToConfluenceAndPrintPageText(version) + print "====================================================================" + print " Paste the following text on the Sprint Releases page in confluence " + print "====================================================================" + print wikiText \ No newline at end of file -- GitLab