Skip to main content
Automating project creation with ScriptRunner and HAPI
Share on socials
Automating project creation in Jira with crane and conveyor belt

Automating project creation with ScriptRunner and HAPI

Hello, I'm Ana, an Atlassian consultant at Nimble Evolution, and I'm excited to share how we automated project creation for a national industrial educational organisation using ScriptRunner for Jira Cloud and HAPI. This tutorial will guide you through the process, helping you implement a similar solution in your own Jira environment.

In our project with the National Industrial Educational Organisation, we faced challenges with manual project setups. To address these, we used ScriptRunner with HAPI to automate project creation, saving significant time and reducing errors. Here's how you can achieve the same.

Interested in how Ana saved her client 30 hours per month?

Prerequisites

Before you begin, ensure you have:

Step 1: Define project templates

First, we need to define the configurations for different project types. In our case, we used Kanban and Scrum types. Update the IDs with your specific scheme IDs.
def kanbanType = [
    issueTypeScheme: 0,            // Replace with your Issue Type Scheme ID
    issueTypeScreenScheme: 0,      // Replace with your Issue Type Screen Scheme ID
    notificationScheme: 0,         // Replace with your Notification Scheme ID
    permissionScheme: 0,           // Replace with your Permission Scheme ID
    workflowScheme: 0,             // Replace with your Workflow Scheme ID
]

def scrumType = [
    issueTypeScheme: 0,            // Replace with your Issue Type Scheme ID
    issueTypeScreenScheme: 0,      // Replace with your Issue Type Screen Scheme ID
    notificationScheme: 0,         // Replace with your Notification Scheme ID
    permissionScheme: 0,           // Replace with your Permission Scheme ID
    workflowScheme: 0,             // Replace with your Workflow Scheme ID
]

Step 2: Retrieve user input

Next, we retrieve the selected template from a custom select list field using HAPI. Ensure you replace customfield_0 with your actual custom field ID.
def issue = Hapi.currentIssue()
def inputTemplate = issue.getCustomFieldValue("customfield_0")?.toLowerCase()  // Replace with your custom field ID

Step 3: Assign project configuration

Use a simple switch-case structure to map the selected template to its respective configuration.
def data = inputTemplate == 'kanban' ? kanbanType : scrumType

Step 4: Add project metadata

Add dynamic attributes such as project name, description, key, and lead using HAPI's methods.
data['name'] = issue.summary
data['description'] = issue.description
data['key'] = issue.getCustomFieldValue("customfield_0")  // Replace with the custom field used for the project key
data['leadAccountId'] = issue.assignee?.accountId
data['projectTypeKey'] = 'software'

Step 5: Create the project

HAPI simplifies the project creation process by abstracting REST API calls into straightforward methods.
def projectCreationResult = Hapi.projectManager.createProject(data)

if (projectCreationResult) {
    Hapi.issueManager.updateIssue(issue.key, [
        customfield_0: projectCreationResult.key  // Replace with your custom field for saving project key
    ])
} else {
    // Handle project creation failure
    Hapi.logger.info('Project creation failed. Please check the details and try again.')
}

Conclusion

By following these steps, you can automate project creation in Jira Cloud using ScriptRunner and HAPI, just as we did for our client. This automation not only saves time but also minimises errors, allowing your team to focus on more strategic tasks. If you have any questions or need further assistance, feel free to reach out.
Happy automating!

Thirsting for more Jira Cloud wisdom?

Level up your Jira Cloud instance with the tutorial below,
Published on 17 September 2025
Authors
Headshot of Ana Vitória Selista
Ana Vitória Selista
Share this tutorial