changelog.py: Allow to define project, make custom_fields and changes optional

fixes #9446
This commit is contained in:
Michael Friedrich 2015-06-18 13:26:59 +02:00 committed by Gunnar Beutner
parent a2ed9f78f3
commit 5d9647fb7e
1 changed files with 22 additions and 17 deletions

View File

@ -28,8 +28,9 @@ version_name = sys.argv[1]
link_issues = (len(sys.argv) >= 3 and sys.argv[2] == "link-issues") link_issues = (len(sys.argv) >= 3 and sys.argv[2] == "link-issues")
issue_url = "https://dev.icinga.org/issues/" issue_url = "https://dev.icinga.org/issues/"
issue_project = "i2"
rsp = urllib2.urlopen("https://dev.icinga.org/projects/i2/versions.json") rsp = urllib2.urlopen("https://dev.icinga.org/projects/%s/versions.json" % (issue_project))
versions_data = json.loads(rsp.read()) versions_data = json.loads(rsp.read())
version_id = None version_id = None
@ -45,6 +46,7 @@ if version_id == None:
changes = "" changes = ""
if "custom_fields" in version:
for field in version["custom_fields"]: for field in version["custom_fields"]:
if field["id"] == 14: if field["id"] == 14:
changes = field["value"] changes = field["value"]
@ -54,6 +56,8 @@ changes = string.join(string.split(changes, "\r\n"), "\n")
print "### What's New in Version %s" % (version_name) print "### What's New in Version %s" % (version_name)
print "" print ""
if changes:
print "#### Changes" print "#### Changes"
print "" print ""
print changes print changes
@ -66,7 +70,7 @@ log_entries = []
while True: while True:
# We could filter using &cf_13=1, however this doesn't currently work because the custom field isn't set # We could filter using &cf_13=1, however this doesn't currently work because the custom field isn't set
# for some of the older tickets: # for some of the older tickets:
rsp = urllib2.urlopen("https://dev.icinga.org/projects/i2/issues.json?offset=%d&status_id=closed&fixed_version_id=%d" % (offset, version_id)) rsp = urllib2.urlopen("https://dev.icinga.org/projects/%s/issues.json?offset=%d&status_id=closed&fixed_version_id=%d" % (issue_project, offset, version_id))
issues_data = json.loads(rsp.read()) issues_data = json.loads(rsp.read())
issues_count = len(issues_data["issues"]) issues_count = len(issues_data["issues"])
offset = offset + issues_count offset = offset + issues_count
@ -77,6 +81,7 @@ while True:
for issue in issues_data["issues"]: for issue in issues_data["issues"]:
ignore_issue = False ignore_issue = False
if "custom_fields" in issue:
for field in issue["custom_fields"]: for field in issue["custom_fields"]:
if field["id"] == 13 and "value" in field and field["value"] == "0": if field["id"] == 13 and "value" in field and field["value"] == "0":
ignore_issue = True ignore_issue = True