Get TaskContext From AbstractTaskConfigurator Class

I want to populate the default values (in GUI / FTL) of my task based on TaskContext. 


I'm my case, I want to show all available DeploymentProjects for this plan (as used by task). 

This can be easily achived inside of my task using : deploymentProjectService.getDeploymentProjectsRelatedToPlan(parentPlanKey) ... since I have access to the TaskContext.

I'm not however sure how to achive this in my Configuration Class .. which extends from AbstractTaskConfigurator.

Thanks

 

 

 

1 answer

1 accepted

This widget could not be displayed.

First of all, you should not use server-side services in Tasks implementations, they are only allowed to be used in Configurators.

As it is, your task will fail on remote agents. You should make sure all data you need to execute task is either stored in task configuration or injected into RuntimeTaskDefinition using RuntimeTaskDataProvider class.

Answering your question:

 

public void populateContextForEdit(@NotNull final Map<String, Object> context, @NotNull final TaskDefinition taskDefinition) {
     
PlanKey parentPlanKey = TaskContextHelper.getPlan(context).getPlanKey();
deploymentProjectService.getDeploymentProjectsRelatedToPlan(parentPlanKey)
//....
}

 

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

99 views 1 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you