Hi I am learning script runner.
As a beginner my use case is, In jira cloud when issue moves to inprogress state i want to add label to the issue as "Test"
Guide me with steps to achieve the same.
Here is the code that will work for script runner cloud
Issues.getByKey(issue.key as String).update{
setLabels{
add("TestLabel")
}
}
Hello @K Vivek Rao ,
Since you said, CLOUD + Scriptrunner, here's the snippet for it:
List labels = issue.fields.labels ?: [] // get the labels for the current issue
labels += "newLabel"
issueInput.fields.labels = labels
Alternatively, you can use JIRA Automation to perform the actions.
Tip: While adding a labels, add to existing labels, else one may replace all with new.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you @Piyush Annadate _ACE Pune_ for your input, but i am getting the error as attached. I am configuring it as a part of post-function on In Progress transition.
If issue is moved to In progress state, a label "test" should be added under lables, it should append not replacing.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
With post function, you can just added as below:
issueInput.update.labels = [[set: ["example"]]] // to set just the value.
List<String> labels = Issues.getByKey(issue.key).getLabels()?.collect { it.label } ?: [] // get the labels for the current issue
labels += "updateLabel"
issueInput.fields.labels = labels
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you prefer a no-code solution, Jira Automation can achieve the same result. Follow these steps:
Create a New Automation Rule:
Go to the project settings and navigate to Automation.
Click on "Create Rule."
Set the Trigger:
Select the "Issue Transitioned" trigger.
Configure the trigger to fire when the issue transitions to the "In Progress" state.
Add a Condition (Optional):
If needed, add a condition to ensure the rule only applies to specific issues or projects.
Add an Action:
Select the "Edit Issue" action.
In the "Fields to Set" section, choose "Labels."
Add the label "Test" to the field. If other labels exist, ensure they are preserved by appending "Test" rather than overwriting the field.
Save and Enable the Rule:
Review the rule configuration.
Save and enable the rule.
Test the Automation:
Transition an issue to the "In Progress" state and verify that the "Test" label is added automatically.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I know this jira automation, i was specifically asking for Script runner
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jira Product Discovery Premium is now available! Get more visibility, control, and support to build products at scale.
Learn moreOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.