I’ve set up a pipeline in a GitLab.com project to deploy a set of applications. It’s divided into separate, manually-activated jobs for each environment. When each job completes, I’d like to send a Slack message with a list of all the issues that specific deployment closes. Here’s one approach to getting that list for a single application, assuming I’ve already written the code to associate the last deployment and this deployment with specific commits:
- Get the full list of commits between the two deployments using either GitLab’s API or Git.
- For each commit, fetch the list of associated merge requests.
- Fetch the details of each of those MRs to narrow it down to a single MR that was closed during this period (if available; skip otherwise).
- For every merge request in the resultant set, get the list of issues it closes.
However, this would require many requests: at least one to get the list of commits, one per commit in the list, probably one more per commit to get the details of each MR, plus one more per MR to get the list of issues it closes. Ideally, I’d extend this to add a comment about the deployment to each of the closed issues, but that would require even more requests. And I’d have to repeat all of these requests for every application.
Is there a more efficient way to get that list of issues? What about adding the comments? I’d be very happy to hear I’ve missed something obvious and there’s no need for me to do any of this by hand, of course!