0
votes

I'm trying to automate the creation of project in Jira(server). In our server we are using our own workflows, issue types, notification schemes, permissions, fields, screens, priority schemes. Also after creating the project we need to add this project to some of the custom fields, script listeners, requirements project Xrays and Behaviours.

We tried this using Selenium, but later we came to know that after every deployment or upgrade our UI will change. Then I researched a lot to do it using Rest-API, but still not able to find a way to do so using our own configurations to that project. As this is a Jira Server we can only able to use Rest-API version 2. ~https://docs.atlassian.com/software/jira/docs/api/REST/7.13.0/#api/2/project-createProject

Can someone please suggest me is there any way to automate my Jira server project creation?

FYI, we are usng Jira version - 7.13.6

Note: Recommended Language - Python

1
you can use requests library of python. Give it a try. show us what you have tried then ppl here would love you assist you. :) - Tarique

1 Answers

0
votes

I have the same Problem. So its a lot of work, the Jira API is really.. bad.

So at first, the user Tarique is right. Use requests for that first. Note that u dont have to json.dumps(...) this, u can just add json=payload in the request.post part. Lets go to the next Problem.

You have to look for the Scheme-IDs. And even if u have the right ID's, the Project is still not configured. So you have to setup the Board by urself. U cant do this via API, there is a way to see the Configuration so - GET Configuration. But u are not able to SET Configs. I spend three Days to search for a solution but i gave up and will do this later.

Here is a unoffical Endpoint:

https://ur-domain.net/rest/project-templates/1.0/createshared/projectID

So this Endpoint is basically a copy from the Project u specify in ProjectID. They said that you are able to Copy a Project with all its Configurations and Settings. But if you do this, the Project is.. disabled u cant work with it. So i tried to Update this Project, to give him Schemes and a Template. Nothing works.

So there are some Addons u can use, they will Copy a whole Project for you. Some of them are Free, some of them not. During my research if found no way to Clone a Project or/and add Configs/Settings via API to it. You write a Programm that can do this for you. Also you can try to Export the Project and Import it aggain with another name. I read this in one Forum, but thats no option for me.

So maybe u should just ask the Support. You can contact ur Admin and tell him that he should tell the support because there is no working way to clone a Project 1:1.

I hope i help u a bit with that, i know my english is not good and its a bit unclear what i want to say. I only want to tell u that we also try lots of stuff so i dont want that u have to do the same!

If you figure anything out, please let me know! If you want i can send u the Requests in Python too. ( For the Schemes, Create Project and Stuff like that )!

I hope that help u a bit and feel free to share with me or ask for some more Informations!

EDIT:

Here is a link for Create Projects. https://docs.atlassian.com/software/jira/docs/api/REST/7.13.0/#api/2/project-createProject

And here a Python Example for Create a Project via request Libary:

def createAProject():

url = "https://ur-domain.net/rest/api/2/project"

auth = getAuth()
headers = getheader()

payload =  {
    "leadAccountId": "insertLeadIDHere",
    "projectTemplateKey": "com.pyxis.greenhopper.jira:gh-simplified-scrum-classic",
    "name": "Name of the Project",
    "key": "The new Key",
    "issueSecurityScheme" : "SchemeID",
    "projectTypeKey": "TypeKey",
    "permissionScheme": "PermissionID",
    "notificationScheme": "NotificationID"
} 


try:
    response = requests.post(
        url,
        json=payload,
        headers=headers,
        auth=auth
    )

    response.raise_for_status()

except HTTPError as err:
    return response.status_code
else:
    return response.status_code