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

1 vote
Accepted answer

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
Community showcase
Published yesterday in Statuspage

194 years of downtime: looking back on incident data from 2018

Statuspage customers logged more than 194 years of collective incidents in 2018. That’s a whopping 87% increase from the  104 years logged in 2017 , and we aren’t even through December yet....

35 views 1 5
Read article

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