Example #1
0
        for name, fields in filters.items():
            try:
                print "filter " + name
                data = {
                    'name': name,
                    'description': fields['description'],
                    'jql': fields['jql'] % constants,
                    'favourite' : 'true'
                }
                
                if 'id' in fields:
                    print 'updating filter ' + name + "->" + data['jql']
                    fields['id'] = shared.jiraupdate(options, "/rest/api/latest/filter/" + fields['id'], data)['id']
                else:
                    print 'creating filter ' + name + "->" + data['jql']
                    fields['id'] = shared.jirapost(options, "/rest/api/latest/filter", data)['id']
                allfilters[name] = fields
                newfilters[name] = fields
                saveFilters(filterfile, newfilters) # saving every succesful iteration to not loose a filter id 
            except urllib2.HTTPError, e:
                print "Problem with setting up filter %s with JQL = %s" % (data['name'], data['jql']);

    print "Jira filters in asciidoc: "
    print "[options=\"header\"]"
    print ".Jira Filters"
    print "|==="
    print "|Name|  Description| Query" 
    for name, fields in allfilters.items():
        print "| https://issues.jboss.org/issues/?filter="+ fields['id'] + "[" + name + "] | " + fields['description'] + "| " + fields['jql']
        
Example #2
0
                data = {
                    'name': name,
                    'description': fields['description'],
                    'jql': fields['jql'] % constants,
                    'favourite': 'true'
                }

                if 'id' in fields:
                    print 'updating filter ' + name + "->" + data['jql']
                    fields['id'] = shared.jiraupdate(
                        options, "/rest/api/latest/filter/" + fields['id'],
                        data)['id']
                else:
                    print 'creating filter ' + name + "->" + data['jql']
                    fields['id'] = shared.jirapost(options,
                                                   "/rest/api/latest/filter",
                                                   data)['id']
                allfilters[name] = fields
                newfilters[name] = fields
                saveFilters(
                    filterfile, newfilters
                )  # saving every succesful iteration to not loose a filter id
            except urllib2.HTTPError, e:
                print "Problem with setting up filter %s with JQL = %s" % (
                    data['name'], data['jql'])

    print "Jira filters in asciidoc: "
    print "[options=\"header\"]"
    print ".Jira Filters"
    print "|==="
    print "|Name|  Description| Query"
    for filterfile in filterfiles:
        print "Processing filters found in " + filterfile
        filters = json.load(open(filterfile, 'r'))

        newfilters = filters.copy()
        for name, fields in filters.items():
            try:
                print "filter " + name
                data = [{
                    'type': 'project',
                    'projectId': 10020
                }, {
                    'type': 'project',
                    'projectId': 12310500
                }]

                if 'id' in fields:
                    print 'Checking filter ' + name
                    filter = shared.jiraquery(
                        options, "/rest/api/latest/filter/" + fields['id'])
                    if len(filter['sharePermissions']) == 0:
                        print 'Updating filter ' + name
                        for permission in data:
                            shared.jirapost(
                                options, "/rest/api/latest/filter/" +
                                fields['id'] + "/permission", permission)
                else:
                    print 'Filter ' + name + ' already has some permissions'
            except urllib2.HTTPError, e:
                print "Problem with setting up filter %s" % (name)