Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How do I upload a zip file from bamboo ondemand to confluence ondeman

William Adelman April 21, 2013

I attempted to do this with a python script that I run as the final step of plan but the script just hangs. Does anyone have an ideas on what I have done wrong in my script? I do see the artifcate and able to download it manually.

This is what my code looks like

#!/usr/bin/python

from __future__ import with_statement
import sys, string, xmlrpclib, re, os, logging

logging.warning('running upload-attachment') 

    #Space key of the page where you want to attach the file. For example, "KEY".
spacekey = 'SIM';

    #Page title of the page where you want to attach the file. The page must already exist. You may need to escape or quote special characters in the file name. For example, "Page title".
pagetitle = "Simpoint Downloads";

    #Content type of the attachment. See below for more information about content types. For example, "text/plain".
contentType = 'application/zip';

    #File name of the file to attach. This will also be used as the name of the attachment within Confluence. For example, "somefile.txt".
filename = 'simpoint/package/target/SimPoint_trunk.zip';

logging.warning('opening file') 
with open(filename, 'rb') as f:
    data = f.read(); # slurp all the data

logging.warning('after openning file') 
server = xmlrpclib.ServerProxy('https://myurl.atlassian.net/wiki');
logging.warning('after server connect') 

token = server.confluence1.login('MyUser', 'MyPassword');
logging.warning('after login') 

page = server.confluence1.getPage(token, spacekey, pagetitle);

logging.warning('getPage') 
if page is None:
    exit("Could not find page " + spacekey + ":" + pagetitle);

attachment = {};
attachment['fileName'] = os.path.basename(filename);
attachment['contentType'] = contentType;

logging.warning('before addAttachment') 
server.confluence1.addAttachment(token, page['id'], attachment, xmlrpclib.Binary(data));
logging.warning('after addAttachment')

3 answers

0 votes
William Adelman April 27, 2013

does anyone have a suggestion for me?

0 votes
William Adelman April 21, 2013

thanks, but I am using ondemand confluence and ondemand bamboo. Any suggestions on how I can solve this problem with that setup?

0 votes
Bob Swift OSS (Bob Swift Atlassian Apps)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 21, 2013

Bamboo for automatic uploads to Confluence is another way to solve this problem :), but only if you are host your own Bamboo :(.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events