How to automate a label addition when sprint is closed
Asked by Jo?o Ribeiro:

Hi,

I would like to automate a spillover label addition when a sprint is closed and also add a comment to that effect.

Many thanks for all the help!


Answers:
author: Neil Fletcher
body: hi [@Jo?o Ribeiro](/t5/user/viewprofilepage/user-id/5551291)

Something like this should work...  

Use the trigger: **When Sprint is completed** - add the board that references the sprint

+

Edit - labels

+

Add - comment

![2024-07-24_09-20-37.png](https://community.atlassian.com/t5/image/serverpage/image-id/337522iF38CE9144B6FCEC9/image-size/large?v=v2&px=999 "2024-07-24_09-20-37.png")

comments: author: Jo?o Ribeiro
body: Hi [@Neil Fletcher](/t5/user/viewprofilepage/user-id/5127667) ,

Thanks for the quick reply. Maybe I did not explain my query correctly, but I only want to add the label \& comment for open tickets when the sprint closes. I've tried to set this up, but getting this warning:

![Screenshot 2024-07-24 at 12.54.05.png](https://community.atlassian.com/t5/image/serverpage/image-id/337609i8A9A021499308AE6/image-size/large?v=v2&px=999 "Screenshot 2024-07-24 at 12.54.05.png")

Any clue why?


author: Neil Fletcher
body: Adding a branch will get you past 'incompatible component' message

To select open tickets only, I added a JQL condition: statuscategory != Done  

(I use statuscategory instead of status as statuscategory is only: To Do, In Progress or Done... all statuses are always grouped beneath these choices.)

![2024-07-24_14-59-57.png](https://community.atlassian.com/t5/image/serverpage/image-id/337625i22AD408F6A579006/image-size/large?v=v2&px=999 "2024-07-24_14-59-57.png")

this is the result for open issues when the current sprint is closed.

The sprint moves to the next one, a comment is added and the label is updated

![2024-07-24_15-00-34.png](https://community.atlassian.com/t5/image/serverpage/image-id/337629i95422EEDF539A820/image-size/large?v=v2&px=999 "2024-07-24_15-00-34.png")


author: Jo?o Ribeiro
body: Thanks [@Neil Fletcher](/t5/user/viewprofilepage/user-id/5127667)


author: Julio Herrera
body: Automating label addition when a sprint is closed can be achieved by leveraging workflow automation tools provided by project management platforms like **Jira, Trello, or GitHub.** Here's how you can approach this automation using different tools:

<br />

**Using Jira-**

Jira provides powerful automation features that can be used to automate tasks such as adding labels when a sprint is closed.

Navigate to Project Settings: Go to the project where you want to set up the automation.  
Automation Rules:  
Go to Project Settings \> Automation.  
Click on Create Rule.  
Create a New Rule:  
Trigger: Select Sprint Completed as the trigger.  
Action: Select Edit Issue.  
Edit Labels: In the action configuration, set the label you want to add to the issues in the sprint.  
Save and Enable: Save the rule and ensure it is enabled.

Here's a detailed step-by-step:

Trigger: When the sprint is completed.  
Condition (optional): Add any conditions you might need.  
Action: Edit issues \> Add labels.

**Using Trello-**

For Trello, you can use Butler (Trello's automation tool):

Open Butler:  
Go to your Trello board.  
Click on Automation.  
Create a New Command:  
Choose Calendar or Due Date.  
Set the trigger for when a sprint ends (you might need to manually set the end date for sprints).  
Add an Action:  
Action: Add a label to all cards in the sprint list.  
Save Command: Save and enable the automation.

**Using GitHub-**

If you're using GitHub Projects, you can use GitHub Actions:

Create a Workflow:  
In your repository, go to Actions.  
Click on New Workflow.  
Set Up Trigger:  
Use a cron job or a specific event that signifies the end of a sprint.  
Define the Action:  
Use the actions/labeler GitHub Action to add labels to issues or PRs.

Example Workflow:

yaml

name: Add label when sprint closes

on:  
workflow_dispatch:  
schedule:  
- cron: '0 0 \* \* 0' # This runs every Sunday, adjust as necessary

jobs:  
add-label:  
runs-on: ubuntu-latest  
steps:  
- name: Add Label  
uses: actions/github-script@v3  
with:  
script: \|  
const issues = await github.issues.listForRepo({  
owner: context.repo.owner,  
repo: context.repo.repo,  
labels: 'sprint-ending', // Adjust based on how you track sprint end  
});  
for (const issue of issues.data) {  
await github.issues.addLabels({  
owner: context.repo.owner,  
repo: context.repo.repo,  
issue_number: issue.number,  
labels: \['sprint-closed'\]  
});  
}

These steps allow you to automate the process of adding labels when a sprint is closed, ensuring consistency and saving time.

comments: author: Jo?o Ribeiro
body: Hi [@Julio Herrera](/t5/user/viewprofilepage/user-id/5547886)

Thanks for the quick reply. That is what I've tried to achieve but have this warning:

![Screenshot 2024-07-24 at 12.54.05.png](https://community.atlassian.com/t5/image/serverpage/image-id/337609i8A9A021499308AE6/image-size/large?v=v2&px=999 "Screenshot 2024-07-24 at 12.54.05.png")

Any clue why?


author: Julio Herrera
body: I don't why this error is coming, I will research it and let you know!


Tags: cloud

jira

jira-cloud