How to create projects or sets of issues based on a template

Description

Many organizations need to create projects, sets of issues, components, and other things based on a standard process. This shows how to automate doing this type of activity to ensure consistency. This example is based on using the run action, but similar techniques (runFromCsv, et...) work similarly.

Can be added to administrator UI

See Administrator UI to Run CLI Actions. There you can easily save the template and run it from the Administrator UI on a regular basis. This requires the Run CLI Actions in Jira product.

If you use Confluence in your organization

How to create a self service create project page describes a technique for offloading administrative tasks like this to project leaders.

Steps

  1. Create an action script. Note the use of Variable Replacements

    Example action script
    # Create a project with standard issues and subtasks
    --action createProject --lead automation
     
    --action createIssue --type improvement --summary "Phase 1" --date #dueDateP1# 
    --action createIssue --parent @issue@ --type sub-task --summary "Task 1" --date #dueDateP1T1# 
    --action createIssue --parent @issue@ --type sub-task --summary "Task 2" --date #dueDateP1# 
    
    --action createIssue --type improvement --summary "Phase 2" --date #dueDateP2#  
    --action createIssue --parent @issue@ --type sub-task --summary "Task 1" --date #dueDateP2T1# 
    --action createIssue --parent @issue@ --type sub-task --summary "Task 2" --date #dueDateP2#
     
    ... other actions
  2. Run the action from a command line.

    Command
    jira --action run --file example.txt --common "--project ExampleA  --dateFormat yyyy-MM-dd" --findReplace "#dueDateP1#:2012-09-30,#dueDateP1T1#:2012-09-15,#dueDateP2#:2012-10-30,#dueDateP2T1#:2012-10-15"
    Results
    Run: --project ExampleA  --dateFormat yyyy-MM-dd --action createProject --lead automation
    Project 'ExampleA' created with key EXAMPLEA and id 44450.
    
    Run: --project ExampleA  --dateFormat yyyy-MM-dd --action createIssue --type improvement --summary "Phase 1" --date 2012-09-30
    Issue EXAMPLEA-1 created with id 173430. URL: http://example.com/browse/EXAMPLEA-1
    
    Run: --project ExampleA  --dateFormat yyyy-MM-dd --action createIssue --parent EXAMPLEA-1 --type sub-task --summary "Task 1" --date 2012-09-15
    Issue EXAMPLEA-2 created with id 173431 as subtask of EXAMPLEA-1. URL: http://example.com/browse/EXAMPLEA-2
    
    Run: --project ExampleA  --dateFormat yyyy-MM-dd --action createIssue --parent EXAMPLEA-1 --type sub-task --summary "Task 2" --date 2012-09-30
    Issue EXAMPLEA-3 created with id 173432 as subtask of EXAMPLEA-1. URL: http://example.com/browse/EXAMPLEA-3
    
    Run: --project ExampleA  --dateFormat yyyy-MM-dd --action createIssue --type improvement --summary "Phase 2" --date 2012-10-30
    Issue EXAMPLEA-4 created with id 173433. URL: http://example.com/browse/EXAMPLEA-4
    
    Run: --project ExampleA  --dateFormat yyyy-MM-dd --action createIssue --parent EXAMPLEA-4 --type sub-task --summary "Task 1" --date 2012-10-15
    Issue EXAMPLEA-5 created with id 173434 as subtask of EXAMPLEA-4. URL: http://example.com/browse/EXAMPLEA-5
    
    Run: --project ExampleA  --dateFormat yyyy-MM-dd --action createIssue --parent EXAMPLEA-4 --type sub-task --summary "Task 2" --date 2012-10-30
    Issue EXAMPLEA-6 created with id 173435 as subtask of EXAMPLEA-4. URL: http://example.com/browse/EXAMPLEA-6
    
    Run completed successfully. 7 actions were successful from file: example.txt

Use common

--common is used to avoid duplicating parameters across many of the actions. It simply provides all the parameters on each of the actions run. Only include parameters that will not duplicate provided parameters and provide the correct value on all actions being run.

Use findReplace

Use --findReplace or --findReplaceRegex to parameterize your action script to enforce rules or prevent duplication.

How to reference previously created issue keys?

For example, you make want to link issues together with the linkIssue action. See How to reference previously created issue keys in a JCLI script?

Confluence installed?

If you have Confluence, you can do this kind of administrative action from a page using the Run CLI Actions in Confluence - How to semi-automate repetitive tasks

Automate as part of a JIRA workflow

The Run CLI Actions in Jira provides a way to do this kind of activity as part of a workflow. Your process could have a "Create a new project" task that drives the automation to create the project from a workflow based on custom field settings.

More automation for subtask creationg

Use the Create on Transition for Jira to create subtasks on a specific workflow step instead of (or in addition to) doing them at the creation of a project.

Use cloneIssue or cloneIssues actions with or without the Clone Plus for Jira to copy issues.