How to define Screens in Project Template

Hi,

is there a way to define Screens, Screen Schemes and Issue Type Screen Schemes when setting up a project template for Jira? I think this should be done in the config.json file for the template, but I cant find any documentation about it (only how to define issue types and workflows).

Thanks!

2 Likes

Hi @andreas2,

Have you found a way to do this? Thanks!

Hey, I know this is an old one, but we do this manually through the AddProjectHook implementation sending an event to a Project Creation Listener and dealing with configuration there.

@Component
@Scanned
public class MyAddProjectHook implements AddProjectHook
{
    @ComponentImport
    private final EventPublisher eventPublisher;

    @Inject
    public MyAddProjectHook (EventPublisher eventPublisher) {
        this.eventPublisher = eventPublisher;
    }

    public ValidateResponse validate(final ValidateData validateData)
    {
        ValidateResponse validateResponse = ValidateResponse.create();
        if (validateData.projectKey().equals("TEST"))
        {
            validateResponse.addErrorMessage("Invalid Project Key");
        }

        return validateResponse;
    }

    public ConfigureResponse configure(final ConfigureData configureData)
    {
        // Notifies our Project Creation Listener that we are using MY_TEMPLATE
        eventPublisher.publish(new CreatedWithTemplateEventImpl(CreatedWithTemplateEventImpl.MY_TEMPLATE.MY_TYPE));

        return ConfigureResponse.create();
    }
}

Now, on the Project Created Listener, we check if the MY_TEMPLATE event was triggered

@Scanned
public class ProjectCreatedConfigurationListener implements InitializingBean, DisposableBean {

    @ComponentImport
    private final EventPublisher eventPublisher;

    private CreatedWithTemplateEvent.MY_TEMPLATE template = CreatedWithTemplateEvent.MY_TEMPLATE.NONE;

    @Inject
    public ProjectCreatedConfigurationListener (EventPublisher eventPublisher) {
        this.eventPublisher = eventPublisher;
    }

    /**
     * Called when the plugin has been enabled.
     */
    public void afterPropertiesSet() throws Exception {
        // register ourselves with the EventPublisher
        eventPublisher.register(this);
    }

    /**
     * Called when the plugin is being disabled or removed.
     * @throws Exception
     */
    public void destroy() throws Exception {
        // unregister ourselves with the EventPublisher
        eventPublisher.unregister(this);
    }

    /**
     * Receives any {@code ProjectCreatedEvent}s sent by JIRA.
     * @param projectTemplateEvent the IssueEvent passed to us by the Hook class
     */
    @EventListener
    public void onProjectConfigure(CreatedWithTemplateEventImpl projectTemplateEvent) {
        this.template = projectTemplateEvent.getType();
    }

    /**
     * Receives any {@code ProjectCreatedEvent}s sent by JIRA.
     * @param projectCreatedEvent the IssueEvent passed to us
     */
    @EventListener
    public void onProjectCreate(ProjectCreatedEvent projectCreatedEvent) {
        final Project project = projectCreatedEvent.getProject();

        // Configure the project

        // Flush the template type, you can synchronize around it to avoid projects being created simultaneously!
        this.template = CreatedWithTemplateEventImpl.MY_TEMPLATE.NONE;
    }

Hope this helps

An excerpt from one of mine.

{
  "issue-type-scheme":
  {
    "name": "MyTemplate Issue Type Scheme",
    "description": "",
    "default-issue-type": "taskType",
    "issue-types": [
      {
        "key": "epicType",
        "name": "Epic",
        "description": "A big user story that needs to be broken down.",
        "avatar": "/images/svg/epic.svg",
        "icon": "/images/png/epic.png",
        "screen-scheme":"epicDefaultScreenScheme"
      },
      {
        "key": "taskType",
        "name": "Task",
        "description": "A task that needs to be done.",
        "avatar": "/images/png/task.svg",
        "icon": "/images/png/task.png"
      },
      {
        "key": "requestType",
        "name": "Request",
        "description": "A request that needs to be done.",
        "avatar": "/images/png/task.png",
        "icon": "/images/png/task.png"
      },
      {
        "key": "subtaskType",
        "name": "Sub-Task",
        "description": "A sub-task of the issue.",
        "avatar": "/images/png/subtask.svg",
        "icon": "/images/png/subtask.png",
        "screen-scheme":"subtaskDefaultScreenScheme",
        "sub-task": true,
        "workflow": "simpleWorkflow"
      }
    ]
  },
  "workflow-scheme":
  {
    "name": "MyTemplate Workflow Scheme",
    "description": "",
    "default-workflow": "customerWorkflow",
    "workflows": [
      {
        "key": "customerWorkflow",
        "name": "Standard Customer Workflow",
        "description": "Basic 4-step customer interaction workflow.",
        "workflow-bundle": "/workflows/Standard-Customer-Workflow-1.0.jwb"
      },
      {
        "key": "simpleWorkflow",
        "name": "Standard Simple Workflow",
        "description": "Basic 2-step workflow for JIRA new project creation blueprint.",
        "workflow-bundle": "/workflows/Standard-Simple-Workflow-1.1.jwb"
      }
    ]
  },
  "issue-type-screen-scheme":
  {
    "name": "Request Issue Type Screen Scheme",
    "description": "A collection of tabs and fields, used for tracking Tasks and Projects.",
    "default-screen-scheme": "taskDefaultScreenScheme",
    "screens": [
      {
        "key": "taskDefaultScreen",
        "name": "Task Tracking Default Screen",
        "tabs": [
          {
            "name": "Field Tab",
            "fields":[
              "issuetype",
              "summary",
              "description",
              "attachment",
              "security",
              "components",
              "priority",
              "duedate",
              "reporter",
              "assignee",
              "labels"
            ]
          }
        ]
      },{
        "key": "epicDefaultScreen",
        "name": "Task Tracking Epic Screen",
        "tabs": [
          {
            "name": "Field Tab",
            "fields":[
              "summary",
              "description",
              "attachment",
              "security",
              "components",
              "priority",
              "duedate",
              "reporter",
              "assignee",
              "labels"
            ]
          }
        ]
      },{
        "key": "subtaskDefaultScreen",
        "name": "Task Tracking Subtask Screen",
        "tabs": [
          {
            "name": "Field Tab",
            "fields":[
              "summary",
              "description",
              "attachment",
              "security",
              "components",
              "priority",
              "duedate",
              "reporter",
              "assignee",
              "labels"
            ]
          }
        ]
      }
    ],
    "screen-schemes": [
      {
        "key": "taskDefaultScreenScheme",
        "name": "Task Tracking Default Screen Scheme",
        "default-screen": "taskDefaultScreen"
      },{
        "key": "epicDefaultScreenScheme",
        "name": "Task Tracking Epic Screen Scheme",
        "default-screen": "epicDefaultScreen"
      },{
        "key": "subtaskDefaultScreenScheme",
        "name": "Task Tracking Subtask Screen Scheme",
        "default-screen": "subtaskDefaultScreen"
      }
    ]
  }
}
3 Likes

How Can I associate this screen to workflow transition? Is it possible to do using JSON file ?

You should create a new question for new questions.

In my case, I usually accomplish this by including the screen in the JWB file or creating a hook to add the screen to the workflow after the fact. Including the screen in the JWB will create a NEW screen for each template, whereas using the Hook to assign it will allow you to reuse existing screens.

1 Like

Hello @anon32245848

The transitions screens are included into the wfb file containing the workflow. So you have to create the transitions screens in the jira workflows editor, and adding the workflows file to your JSON template. The screens will be created automatically when creating a project with the new template.

For others screens , there is no native way to includes them into the JSON of a template file. The solution we have setup with my team is to develop a post creation step where we create the screen according to a section we added in the JSON (which describe the screens)

You can create the screens after the project is created by using

  • a class implementing AddProjectHook as @steve.behnke said
  • a class implementing ProjectCreateHandler (append after the hook and others configuration steps of jira, may help you if you encounter some issues with your configuration been override)
1 Like

Hi @diego.ferreira, by chance can you provide a bit more detail on how you used this? Where did you create, “MY_TEMPLATE”? Did you create a project first,? Or is the template in the json? Sorry for the dumb questions, but I’m in the process of creating some templates and would appreciate any assistance.

MY_TEMPLATE is just an enum, you can define it anywhere you’d like… it’s just a way to pass down which template the user has triggered for example.

This is totally dissociated with the default blueprint templating - it’s just a way to configure the project further upon creation.

If your project template defines a specific scheme (screen, issue type…) you can use that as reference to trigger the expected configuration. Not optimal though

I took your example json project template and now I want to add some custom fields to the screens. I cannot find any examples of how to do that. Can you give me a clue? Also, I cannot find an overview of which other configurations may be setup in the template json as well.

Hello!

Here is an overview of what you can setup in the json: ConfigTemplateImpl (Atlassian JIRA 7.6.1 API) :slight_smile:

1 Like

Thanks, I was looking for the part about the reusing.