0

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

  • 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 May 14 '20 at 08:01

1 Answers1

0

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
sheep64
  • 94
  • 1
  • 4
  • Thank you both for the detailed info. I'm not clear regarding the project template key. I don't know which template we are using. Can you suggest a way how to get the project template key we are using for a project. In general in our project we will create a project using shared configuration, where we call the previous referenced projects as template and I can see the workflows, notification schemes used in that project, but am not able to find project template key. Please suggest me a way to find that – poorna sandeep May 16 '20 at 15:16
  • seems like thaer there is no way to figure out which template u use. i mean u can try and error or stuff like that, but there is no endpoint for that. So this works for u? The create project with shared configs? what are you doing and looks ur project good? is the board configured? Because when i use the create project with shared configs, nothing works. – sheep64 May 18 '20 at 08:38
  • We are currently creating the project with shared configuration manually. I'm trying to automate this. But I think this will not help. I need to find out a way to get the project template. Any way thank you for your help.I will reach out to you if I need some help. – poorna sandeep May 20 '20 at 09:30
  • yea man! ill have to research soon too, maybe ill try to contact the support. if i have anything for u, ill let u know. – sheep64 May 20 '20 at 09:42
  • I tried running the code you sent, but I'm getting SSL certificate error. I tried downloading my certificate and added that using keytool, but still not able to sort that error. Traceback (most recent call last): File "C:\Users\sandeep\PycharmProjects\sparkflow_create_project\venv\lib\site-packages\urllib3\util\ssl_.py", line 336, in ssl_wrap_socket context.load_verify_locations(ca_certs, ca_cert_dir) ssl.SSLError: [X509] no certificate or crl found (_ssl.c:4185) – poorna sandeep Jun 09 '20 at 06:40