Skip to content

Custom Label Updation to Jira Issues on every cron call of this Script #1

@gomathishankar37

Description

@gomathishankar37

Construct the custom team label for the current week something like gold_2404_w3...

  • gold -> Team label
  • 24 -> 2024
  • 04 -> April
  • w3 -> 3rd week of April
import datetime

def labeller(current_date):
    year = str(current_date.year)[2:]
    month = str(current_date.month).zfill(2)
    week_number_of_month = (current_date.day - 1) // 7 + 1
    label = "crystal_" + year + month + "_w" + str(week_number_of_month)
    # debug
    print(f"{current_date} | {year} | {month} | {week_number_of_month} |>>>> {label}")
    
    response = requests.post(update_labels_api, auth=(username, password), headers=headers, json={"labels": [label]})
    # Check if the request was successful
    if response.status_code == 204:
        print(f"Label '{label}' added to issue '{issue_key}' successfully.")
    else:
        print(f"Failed to add label '{label}' to issue '{issue_key}'. Status code:", response.status_code)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions