Using SR4Bamboo is it possible to change the display name of a Plan branch. the name will be generated dynamically based on certain values.
Hi @krishnanayak,
Thank you for your post.
Yes, it is possible to change the display name of a Plan branch. To do so, I have tried the following:
- Create a new “Custom event handler” using ScriptRunner for Bamboo.
- In the “Events” field select the " BuildConfigurationUpdatedEvent".
- Use the following Custom Script:
import com.atlassian.bamboo.plan.branch.ChainBranch
import com.atlassian.bamboo.plan.PlanManager
import com.atlassian.sal.api.component.ComponentLocator
def planManager = ComponentLocator.getComponent(PlanManager)
def newBranchPlan = planManager.getPlanByKeyIfOfType(event.getPlanKey(), ChainBranch)
if (newBranchPlan != null) {
newBranchPlan.setBuildName("NEW_BRANCH_PLAN_NAME")
planManager.savePlan(newBranchPlan)
}
You will then need to edit the Script to your needs. For example replacing “NEW_BRANCH_PLAN_NAME” with the name you are generating dynamically.
Note also, there is a “BuildCreatedEvent” in Bamboo. However this does not appear to be currently available to the “Custom event handler”, so I was unable to try that event out.
Hope this helps answer your question?
Kind regards,
Robert Giddings,
Product Manager, ScriptRunner for Bamboo
1 Like