Skip to content

Instantly share code, notes, and snippets.

@ralphbean
Created October 3, 2023 20:17
Show Gist options
  • Save ralphbean/1e04c20f998e529996ee769493081858 to your computer and use it in GitHub Desktop.
Save ralphbean/1e04c20f998e529996ee769493081858 to your computer and use it in GitHub Desktop.
List contributors on a JIRA
#!/usr/bin/env python
import argparse
import os
import sys
import jira
def get_args():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
"feature",
help="Key of the feature we are reporting on",
)
return parser.parse_args()
def main(url, token, args):
JIRA = jira.client.JIRA(server=url, token_auth=token)
all_fields = JIRA.fields()
jira_name_map = {field["name"]: field["id"] for field in all_fields}
contributors_key = jira_name_map["Contributors"]
query = f"key={args.feature}"
results = JIRA.search_issues(query)
for result in results:
people = getattr(result.fields, contributors_key)
for person in people:
print(f'{person.displayName} <{person.emailAddress}>')
if __name__ == "__main__":
args = get_args()
url = os.environ.get("JIRA_URL", "https://issues.redhat.com")
token = os.environ.get("JIRA_TOKEN")
if not token:
print("Set JIRA_TOKEN environment variable to your JIRA personal access token")
sys.exit(1)
main(url, token, args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment