From f96e3992b1fde41b2c3aa3cb8442246b32563ee8 Mon Sep 17 00:00:00 2001 From: Amir Mohammadi <183.amir@gmail.com> Date: Tue, 10 Jan 2017 23:09:24 +0100 Subject: [PATCH] Add create_merge_request ability to our gitlab wrapper class --- nightlies/trigger_pipelines.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/nightlies/trigger_pipelines.py b/nightlies/trigger_pipelines.py index 4e1b10b..aa86195 100755 --- a/nightlies/trigger_pipelines.py +++ b/nightlies/trigger_pipelines.py @@ -91,6 +91,22 @@ class Gitlab(object): pipeline = subprocess.check_output(cmd) return json.loads(pipeline.decode()) + def create_merge_request(self, project_id, source_branch, target_branch, title, + assignee_id='', description='', target_project_id='', + labels='', milestone_id='', remove_source_branch=''): + url = "projects/{}/merge_requests?" + url += "&".join(['source_branch={}', 'target_branch={}', 'title={}']) + url += "&".join(['assignee_id={}', 'description={}', 'target_project_id={}', + 'labels={}', 'milestone_id={}', 'remove_source_branch={}']) + url = url.format(project_id, source_branch, target_branch, title, + assignee_id, description, target_project_id, labels, + milestone_id, remove_source_branch) + cmd = ["curl", "--request", "POST", "--header", + "PRIVATE-TOKEN: {}".format(self.token), + self.base_url + url] + pipeline = subprocess.check_output(cmd) + return json.loads(pipeline.decode()) + def main(packages_list): gitlab = Gitlab(os.environ.get('GITLAB_API_TOKEN')) -- GitLab