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

Accepted Answer
1 vote

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 Monday in Jira Ops

Jira Ops Early Access Program Update #1: Announcing our next feature and a new integration

Thanks for signing up for Jira Ops! I’m Matt Ryall, leader for the Jira Ops product team at Atlassian. Since this is a brand new product, we’ll be delivering improvements quickly and sharing updates...

496 views 0 9
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