gitlab: issues edit api

I've been having fun. We needed to load 100's of requirements into gitlab as issues and add lots of labels.

The requirements were extracted from Doors as a CSV file. A smallish program was written to massage the data into a format that was acceptable to gitlab-issue-creator. This project required some small fixes and modifications to work around some issues with the CSV parser library it was using.

The upload of the requirements worked very well.

Now to the more difficult part. The nodejs gitlab library lacks the capability to edit an issue so a little bit of experimenting was required.

Editing of Issues programatically is required as the definitive requirements are in Doors.

Every requirement I uploaded has a Unique ID in Doors and that does not change. In this case the ID has been embedded as one of the labels.

Additional labels were also added to allow sub-requirements to be linked together. Gitlab Issues does not have any way of grouping Issues together other than via labels or related issues (paid version). This is rather limiting IMHO especially for large projects.

The first part of the experiment was to find a requirement:

curl --header "PRIVATE-TOKEN: private-token" > result.txt

This returns the whole set of details for the Issue that has the label 'PROJECT-1325'. This is my unique ID for this issue.

To send the  Issue back with the title and description edited:

curl --request PUT --header "PRIVATE-TOKEN: private-toke" -H "Content-Type: application/json" --data '{"title":"NEW TITLE.","description":"NEW DESCRIPTION"}'

The trick to this is the content-type and the issue number, in this case 3, which was obtained from the response of the first command (iid field).

The idea is that parts of the description are marked and we just update the text in the marked sections. Text outside the marked section is unchanged allowing for task lists to be maintained.

Now I just need to write a small program to automate going through all the 100's of Issues and update them if the requirements have changed as well as to tell me which ones have changed.


  1. You can use 'curl --libcurl test.c rest-of-command' to obtain some sample code that almost mimics the command line options.


Post a Comment