Fetch Review App (environment) URL from Merge Request

I haven’t done this before - I think that the other way around could work, starting at the environments and “join” them with MR pipelines that are deployed into the environment.

Looking at python-gitlab, for more code alike suggestions.

Thinking of the following algorithm in Python code. I haven’t tested it, lacking a test environment. Hope it helps with your own implementation. :slight_smile:

mr_id = 1234
mr = project.mergerequests.get(mr_id)

pipelines = mr.pipelines.list()
environments = project.environments.list()

for p in pipelines:
  for e in environments:
    if p.id == e.pipeline.id:
      print("Found MR %d in pipeline %d and environment URL %s" % (mr_id, p.id, e. web_url))
      sys.exit(0)

# found nothing, maybe exit with an error