Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Get TaskContext From AbstractTaskConfigurator Class

Victor Sz June 16, 2017

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
Answer accepted
Marcin Gardias
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 20, 2017

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
TAGS
AUG Leaders

Atlassian Community Events