def set_bugs_with_priority_as_ready(jira_key, jira=j.setup_jira_object()):
    projects_to_check = ['CLD', 'PROD', 'APPS', 'CORE']
    payload = generate_payload_by_id.generate_payload(jira_key)
    if issue_within_projects(payload, projects_to_check):
        if issue_is_bug(payload) and issue_has_priority(
                payload) and payload['status'] == 'To do':
            transition_to_status(payload['issue_key'], 'Ready for dev', jira)
def get_parent_issue(jira_key, jira=j.setup_jira_object()):
    payload = generate_payload_by_id.generate_payload(jira_key)
    action_issue = None
    if payload['linked_issue_tree']:
        for linked_issue in payload['linked_issue_tree']:
            if linked_issue['type']['inward'] == 'is caused by':
                action_issue = jira.issue(linked_issue['inwardIssue']['key'])
    return action_issue
def manage_cs_notifications(reporter_email,
                            jira_key,
                            jira=j.setup_jira_object()):
    payload = generate_payload_by_id.generate_payload(jira_key)
    payload["reporter_email"] = reporter_email

    notify_cs_team_of_resolved_sdk_issue(payload, jira)
    notify_cs_team_of_deployed_cld_and_prod_issue(payload, jira)
    notify_cs_team_of_sol_issue(payload, jira)
    notify_cs_team_of_doc_issue(payload, jira)
def is_all_sni_child_stories_done(parent_issue, jira=j.setup_jira_object()):
    linked_sni_issues = check_for_linked_issue_by_project(
        parent_issue.key, jira, 'SNI')
    all_child_stories_done = True
    for linked_issue_key in linked_sni_issues:
        linked_issue_payload = generate_payload_by_id.generate_payload(
            linked_issue_key)
        if linked_issue_payload['status'] != 'Done':
            all_child_stories_done = False
            break
    return all_child_stories_done
def rnd_to_rnd_set_ready_for_dev(jira_key, jira=j.setup_jira_object()):
    projects_to_check = ['CLD', 'PROD', 'APPS', 'CORE']
    payload = generate_payload_by_id.generate_payload(jira_key)
    if issue_within_projects(payload, projects_to_check):
        if is_member_of_team(payload['assignee'], 'R&D') and is_member_of_team(
                payload['reporter'], 'R&D'):
            if payload['status'] == 'To Do':
                print payload[
                    'issue_key'], "since the reporter is from rnd team and the issue is assigned to rnd with status todo will change to Ready for dev"
                transition_to_status(payload['issue_key'], 'Ready for dev',
                                     jira)
def component_lead_auto_assign(jira_key, jira=j.setup_jira_object()):
    projects_to_check = ['CLD', 'SDK']
    payload = generate_payload_by_id.generate_payload(jira_key)

    #set issue object since we will need it
    issue = jira.issue(payload['issue_key'])

    if toolbox.issue_is_security_event(payload):
        #handle case of security issue without component set component to Security
        if len(payload['components']) == 0:
            issue.update(fields={"components": [{'name': 'Security'}]})
            payload = generate_payload_by_id.generate_payload(jira_key)

        for component in payload['components']:
            component_lead = toolbox.return_component_lead(
                component, payload['project_name'])
            if component_lead:
                print payload[
                    'issue_key'], 'Will assign issue to product lead:', component_lead
                issue = jira.issue(payload['issue_key'])
                jira.assign_issue(issue, component_lead)
                return True
def link_to_doc_issue(jira_key, jira=j.setup_jira_object()):
    #this function will verify that an issue with the requirment for a doc issue
    #has a valid doc issue with a link to it
    #list of project codes we act upon
    payload = generate_payload_by_id.generate_payload(jira_key)
    projects_to_check = ['SDK', 'CLD', 'PROD', 'APPS', 'CORE']

    if toolbox.requires_documentation(
            payload) and toolbox.issue_within_projects(payload,
                                                       projects_to_check):
        linked_doc_issues = toolbox.check_for_linked_issue_by_project(
            payload['issue_key'], jira, 'DOC')
        if not linked_doc_issues:  #if false means no linked doc issues were found and will create new one
            new_issue_dict = {
                'project': {
                    'key': 'DOC'
                },
                'summary': "Document: " + payload['jira_summary'],
                'description': payload['jira_description'],
                'issuetype': {
                    'name': 'Story'
                },
                'priority': {
                    'name': payload['jira_priority']
                },
                'customfield_10900': {
                    'value': payload['source']
                },
                'customfield_10004': payload['epic'],
                'customfield_11000': payload['release_notes']
            }
            print "will open a new DOC issue with following parameters:"
            print(json.dumps(new_issue_dict, sort_keys=True))

            new_issue = jira.create_issue(fields=new_issue_dict)
            print "New jira issue created:", new_issue.key

            print "Will now link:", jira_key, "to:", new_issue.key
            jira.create_issue_link(type='Problem/Incident',
                                   inwardIssue=jira_key,
                                   outwardIssue=new_issue.key)

            print "Will now assign ", new_issue.key, " to Docs team"
            jira.assign_issue(new_issue, 'docs')

        else:
            print payload[
                'issue_key'], "Is marked as Doc Update required but already has linked DOC issue"
            transition_linked_doc_issues(linked_doc_issues, payload, jira)
            terminate_wont_do_doc_issues(linked_doc_issues, payload, jira)
def update_doc_trigger_status(jira_key, jira=j.setup_jira_object()):
    payload = generate_payload_by_id.generate_payload(jira_key)
    # when a doc project jira is closed, update the linked jira about it
    if payload['status'] == 'Done' and payload[
            'project_name'] == 'DOC' and payload['linked_issue_tree']:
        for linked_issue in payload['linked_issue_tree']:
            if linked_issue['type']['inward'] == 'is caused by':
                action_issue = jira.issue(linked_issue['inwardIssue']['key'])
                #this part will handle new projects
                if action_issue.fields.project.key in [
                        'APPS', 'CORE', 'CLD', 'PROD', 'SDK'
                ]:
                    if action_issue.fields.customfield_12043.value != 'Updated':
                        print 'DOC issue resolved, Will try to update', action_issue.key
                        action_issue.update(
                            fields={'customfield_12043': {
                                'value': 'Updated'
                            }})
def mark_related_undone_tasks_with_warning_comment(jira_key,
                                                   jira=j.setup_jira_object()):
    payload = generate_payload_by_id.generate_payload(jira_key)
    if is_status_done(payload):
        related_issues_list = check_for_related_issues(payload['issue_key'],
                                                       jira)
        if related_issues_list:
            for related_issue in related_issues_list:
                print "checking status of related issue: " + str(related_issue)
                if not is_issue_key_done(related_issue, jira):
                    print "Since " + str(
                        related_issue
                    ) + " is not done will add a release note remarking this issue"
                    un_done_issue = jira.issue(related_issue)
                    new_release_notes = "an issue related to this was marked as done, so adding release notes for notice \n" + payload[
                        'release_notes']
                    un_done_issue.update(
                        fields={'customfield_11000': new_release_notes})
def set_done_issues_with_fixversion_as_deployed(jira_key,
                                                jira=j.setup_jira_object()):
    #list of project codes we act upon
    projects_to_check_new = ['APPS', 'CORE']
    payload = generate_payload_by_id.generate_payload(jira_key)
    if is_status_merged(payload) and issue_within_projects(
            payload, projects_to_check_new):
        for fv in payload['fixversion']:
            if 'deployed' in str(fv):
                print "Issue has fix version and status is done, so converting to deployed state"
                transition_to_status(payload['issue_key'], 'Deployed', jira)

    projects_to_check_old = ['SDK', 'CLD', 'PROD']
    if is_status_done(payload) and issue_within_projects(
            payload, projects_to_check_old):
        for fv in payload['fixversion']:
            if 'deployed' in str(fv):
                print "Issue has fix version and status is done, so converting to deployed state"
                transition_to_status(payload['issue_key'], 'Deployed', jira)
Beispiel #11
0
def bug_set_assignees_component_lead(jira_key, jira=j.setup_jira_object()):
    projects_to_check = ['CLD', 'SDK', 'CORE', 'APPS']
    payload = generate_payload_by_id.generate_payload(jira_key)

    if 'Not set' in payload['components']:
        return False

    if toolbox.issue_within_projects(payload, projects_to_check) and (
            toolbox.issue_is_bug(payload) or toolbox.issue_is_task(payload)):
        # print payload['issue_key'], 'Will allocate bug to component lead if component is specified'

        for component in payload['components']:
            component_lead = toolbox.return_component_lead(
                component, payload['project_name'])
            if component_lead:
                print 'Assigning bug issue to:'
                print payload[
                    'issue_key'], 'Component:', component, 'lead to assign is:', component_lead
                issue = jira.issue(payload['issue_key'])
                jira.assign_issue(issue, component_lead)
                return True
def github_main(request, jira):
    '''
  if a PR is merged then try and find the related jira for it.
  If developer merges in GITHUB to MASTER (from branch) and jira issue status is In Review -
  check the field Manual Testing and transition issue status accordingly:
  when  = 'Not Applicable', change status to Merged-Tested
  when  = 'On Testing Env', change status to Merged-Tested
  when  field is not set, change status to Merged-Tested
  when  = 'on master', change status to Merge-Test On Master
  when  = 'On Production', change status to Merged-Not Tested
  When  = "On Branch", change status to Test On Branch
  '''

    gh_payload = github_generate_pr_payload.generate_payload(request, jira)
    if gh_payload['action'] == 'closed' and gh_payload['merged']:
        print "going to search for a linked issue in jira and if exist will transition to the desired status"
        if gh_payload['linked_jira_issue']:
            print "found a linked jira issue: " + str(
                gh_payload['linked_jira_issue'])
            payload = generate_payload_by_id.generate_payload(
                gh_payload['linked_jira_issue'])
            if payload['project_name'] in [
                    'APPS', 'CORE'
            ] and payload['status'].lower() == 'in review':
                transition_issue_based_on_manual_qa_field(gh_payload, payload)
            else:
                print "github event is not a relevant flow since linked jira issue project name: " + str(
                    payload['project_name']) + ", jira issue status: " + str(
                        payload['status'])
        else:
            print "github event is not a relevant flow since there isn't any linked jira issue related to the github branch"
    else:
        print "github event is not a relevant flow since action: " + str(
            gh_payload['action']) + ", merge: " + str(gh_payload['merged'])

    #overflow if nothing is done
    return "200"
def set_source_by_owner(jira_key, jira=j.setup_jira_object()):
    #this function will run through the cloudinary team structure and
    #will set the owner by the reporter field
    #configure jira issue object
    payload = generate_payload_by_id.generate_payload(jira_key)

    def issue_source_not_defined(payload):
        return (payload['source'] == 'Not set'
                or payload['source'] == 'Unknown'
                or payload['source'] == 'None')

    if not reported_by_yentel(payload) and issue_source_not_defined(payload):
        issue = jira.issue(payload['issue_key'])

        #invoke the teams structure module
        cld_team = cloudinary_teams.load_team_members()

        for team in cld_team:
            if is_member_of_team(payload['reporter'],
                                 team) and payload['source'] != team:
                print "Since the issue was reported by a member of the:", team, "team, will set the source as", team
                issue.update(fields={'customfield_10900': {
                    'value': team
                }})  #set "source" to the dictionary key
def enforce_qa_when_qa_team(jira_key, jira=j.setup_jira_object()):
    payload = generate_payload_by_id.generate_payload(jira_key)
    if is_member_of_team(
            payload['reporter'],
            'QA') and not requires_qa(payload) and issue_is_bug(payload):
        enforce_qa_on_issue(jira_key, 'On Master')