Work with Projects

With HAPI we've made it easy for you to create, modify, and archive projects. 

Create a new project with default values

You can create a new project as follows:

groovy
Projects.create("TIS", "Teams in Space")

Set details when creating a new project

When you create a project, some assumptions are made about fields such as the project lead (set to the current user), the project type (set to business), and the default assignee for the project (set to Unassigned). You can set these values, as well as optional values such as the description or the URL, when you create the project. For example:

groovy
Projects.create("TIS", "Teams in Space") { setLeadAccountId('user account id') setProjectTypeKey('business') setDescription("This is a new project!") setUrl("https://google.com") setDefaultAssigneeToProjectLead() setAvatarId(10001) }


Create a project using a template

You can create a new project using a template as follows:

groovy
Projects.create("TIS", "Teams in Space"){ setProjectTemplateKey('Kanban') }

The project templates available to you are provided through completions. You'll notice the names are the same as those you see when you create a project through Jira.

Retrieve a project by key

You can retrieve a project by key as follows:

groovy
Projects.getByKey("TIS")

Update a project

In this example, we're updating the project key, name, description, and project category and setting the default assignee to unassigned. You can update a project as follows:

groovy
Projects.getByKey("TIS").update { setKey("TEAM") setName("Team proejct") setDescription("This is an updated project!") setDefaultAssigneeToUnassigned() setProjectCategory("Backend projects") }

Delete a project

You can delete a project as as follows:

groovy
Projects.getByKey("TIS").delete()

This also deletes any issues, components and versions related to the project.


Related content


On this page