[{"data":1,"prerenderedAt":279},["ShallowReactive",2],{"workflow-gitlab-merge-request-automation-auto-create-close-existing-mrs-en":3},{"locale_id":4,"workflow_id":5,"title":6,"locale":7,"seo_meta_title":8,"seo_meta_description":9,"seo_keywords":10,"seo_fields":11,"category":12,"tools":15,"tags":23,"variants":24,"status":28,"slug":29,"pricing":30,"created_at":31,"updated_at":32,"outcome":33,"outcome_msg":34,"static":35,"description":38,"documentation":39,"steps":101,"faq":102,"n8n_workflow":103,"created_by":20,"packages":218,"_ssrCustomizations":20},725287,1066,"GitLab Merge Request Automation: Auto-Create & Close Existing MRs","en","Gitlab Merge Request Automation Auto Create Close Existing Mrs","Automate gitlab merge request automation auto create close existing mrs using this n8n template. Deploy instantly and customize workflows to fit your needs.","n8n, GitLab, merge request, MR automation, DevOps, CI/CD, code delivery, branch management, workflow automation, create merge request, close merge request",{"meta_title":8,"meta_description":9,"keywords":10},{"id":13,"name":14},8,"DevOps & IT",[16],{"content_id":17,"locale_id":18,"locale":7,"name":19,"description":20,"display_dropdown":21,"id":18,"parent_id":17,"workflow_count":22},7,17460,"n8n",null,false,811,[],[25],{"variant_type":19,"variant_type_label":19,"version":26,"is_active":27},"1.0.0",true,"published","gitlab-merge-request-automation-auto-create-close-existing-mrs","0.00","2025-11-11T10:40:14.539000Z","2026-01-20T01:47:56.365000Z","Automate your GitLab merge request lifecycle, reducing manual setup time by 100% and ensuring only fresh, active merge requests are awaiting review and merge.","",{"feature":36,"output":37},[],[],"Manual management of GitLab merge requests can be time-consuming, lead to stale MRs, and slow down development cycles. This workflow automatically checks for existing merge requests, closes outdated ones, creates fresh MRs with custom notes, and sets them up for merging, ensuring continuous integration.",{"root":40},{"type":41,"format":34,"indent":42,"version":43,"children":44,"direction":53},"root",0,1,[45,54,59,64,93,97],{"tag":46,"type":47,"format":34,"indent":42,"version":43,"children":48,"direction":53},"h2","heading",[49],{"mode":50,"text":51,"type":52,"style":34,"detail":42,"format":43,"version":43},"normal","GitLab Merge Request Lifecycle Automation","text","ltr",{"type":55,"format":34,"indent":42,"version":43,"children":56,"direction":53},"paragraph",[57],{"mode":50,"text":58,"type":52,"style":34,"detail":42,"format":42,"version":43},"Manual management of GitLab merge requests, including creating new ones, adding comments, and ensuring they're ready for merge, can be repetitive and error-prone. This n8n workflow fully automates this process, maintaining a clean and active merge request queue for your development branches.",{"tag":60,"type":47,"format":34,"indent":42,"version":43,"children":61,"direction":53},"h3",[62],{"mode":50,"text":63,"type":52,"style":34,"detail":42,"format":43,"version":43},"Key Features",{"type":65,"format":34,"indent":42,"version":43,"children":66,"listType":92,"direction":53},"list",[67,72,76,80,84,88],{"type":68,"format":34,"indent":42,"version":43,"children":69,"direction":53},"listitem",[70],{"mode":50,"text":71,"type":52,"style":34,"detail":42,"format":42,"version":43},"Automatically checks for existing open merge requests for a specific source branch.",{"type":68,"format":34,"indent":42,"version":43,"children":73,"direction":53},[74],{"mode":50,"text":75,"type":52,"style":34,"detail":42,"format":42,"version":43},"Intelligently closes any outdated or existing merge requests to prevent duplication.",{"type":68,"format":34,"indent":42,"version":43,"children":77,"direction":53},[78],{"mode":50,"text":79,"type":52,"style":34,"detail":42,"format":42,"version":43},"Seamlessly creates new merge requests with configurable titles and target branches.",{"type":68,"format":34,"indent":42,"version":43,"children":81,"direction":53},[82],{"mode":50,"text":83,"type":52,"style":34,"detail":42,"format":42,"version":43},"Adds custom, descriptive notes to newly created merge requests for better context.",{"type":68,"format":34,"indent":42,"version":43,"children":85,"direction":53},[86],{"mode":50,"text":87,"type":52,"style":34,"detail":42,"format":42,"version":43},"Configures merge requests for pipeline success merging and automated source branch removal.",{"type":68,"format":34,"indent":42,"version":43,"children":89,"direction":53},[90],{"mode":50,"text":91,"type":52,"style":34,"detail":42,"format":42,"version":43},"Schedules regular checks to ensure merge requests are always up-to-date and ready.","bullet",{"tag":60,"type":47,"format":34,"indent":42,"version":43,"children":94,"direction":53},[95],{"mode":50,"text":96,"type":52,"style":34,"detail":42,"format":43,"version":43},"How It Works",{"type":55,"format":34,"indent":42,"version":43,"children":98,"direction":53},[99],{"mode":50,"text":100,"type":52,"style":34,"detail":42,"format":42,"version":43},"This workflow operates on a scheduled basis, typically checking your GitLab project at defined intervals. It first queries GitLab to see if an open merge request already exists for the specified source branch. If an open merge request is found, the workflow proceeds to close it, ensuring that only a single, up-to-date merge request will exist for that branch. If no open MR is found (or after closing an existing one), the workflow then creates a brand new merge request, specifying the source and target branches, along with a custom title. Immediately after creation, it adds predefined custom notes to the new merge request, providing essential information to reviewers. The workflow then introduces a short waiting period (e.g., 30 seconds) to allow for initial pipeline setup or manual approvals. Finally, it sets the merge request to remove the source branch upon a successful merge, streamlining your repository hygiene.","1. **Import the Workflow:** Download and import this n8n workflow into your n8n instance.\n2. **Configure GitLab Credentials:**\n   *   In all HTTP Request nodes (e.g., \"API to Check existing merge request\", \"Create New Merge Request\"), locate the `PRIVATE-TOKEN` header.\n   *   Replace `=gitlabToken` with your actual GitLab Personal Access Token. For security, it's highly recommended to use n8n's built-in Credentials system for this token.\n3. **Set Project and Branch Details:**\n   *   In the URL fields of all HTTP Request nodes, replace `\u003Cprojectid>` with your specific GitLab Project ID.\n   *   Define the workflow variables for `sourceBranchName`, `targetBranchName`, `mergeTitle`, and `mergeComments`. You can use a 'Set' node at the beginning of the workflow or directly replace the expressions (e.g., `=sourceBranchName`) with static values or other dynamic inputs where appropriate.\n4. **Adjust Wait Time (Optional):** In the \"30 secs wait to approve merge request and pipeline to finish1\" node, modify the \"Amount\" parameter to adjust the waiting duration if needed.\n5. **Configure Schedule Trigger:** In the \"Schedule Trigger\" node, set your desired interval for how often the workflow should run (e.g., every 5 minutes, hourly, daily).\n6. **Activate the Workflow:** Save and activate the workflow to put it into action.",[],[104],{"variant":19,"preview":105,"version":26,"notes":107,"workflow":108},[106],"prod/1066/preview/n8n/0717_HTTP_Schedule_Create_Scheduled.png","Initial release with core automation features",{"meta":109,"nodes":110,"pinData":175,"connections":176},{"templateCredsSetupCompleted":27},[111,119,126,132,139,145,149,156,161,168],{"id":112,"name":113,"type":114,"position":115,"typeVersion":118,"alwaysOutputData":27},"b9a807c3-5847-477a-a242-2fdf5b15ba7e","API to Check existing merge request","n8n-nodes-base.httpRequest",[116,117],-840,-20,4.2,{"id":120,"name":121,"type":122,"position":123,"typeVersion":125},"42270a5a-d696-44f3-b2f5-16b2ddb3488c","Is Exists","n8n-nodes-base.if",[124,117],-660,2.2,{"id":127,"name":128,"type":114,"position":129,"typeVersion":118},"d380c943-0525-4976-9e70-c90de1177f0c","Create New Merge Request",[130,131],-440,-200,{"id":133,"name":134,"type":135,"position":136,"typeVersion":138},"600a0ed5-cb68-4479-8aee-55b55f0d8630","Loop Over Items","n8n-nodes-base.splitInBatches",[130,137],160,3,{"id":140,"name":141,"type":114,"position":142,"typeVersion":118},"555643cb-761c-41ec-b983-8e0194851a8d","API to CLOSE existing Merge Request",[143,144],-220,180,{"id":146,"name":147,"type":114,"position":148,"typeVersion":118},"0c94b06a-80e3-4e50-8bac-2bd4015f085e","Add Custom Notes To Merge Request",[143,131],{"id":150,"name":151,"type":152,"position":153,"typeVersion":155},"8e849f4f-2a52-46ba-9e0a-17126a8d966c","30 secs wait to approve merge request and pipeline to finish1","n8n-nodes-base.wait",[154,131],140,1.1,{"id":157,"name":158,"type":114,"position":159,"typeVersion":118},"05cca829-b2df-4c1e-9441-56349acc4a0d","Merge When Pipeline Succeeds",[160,131],720,{"id":162,"name":163,"type":164,"position":165,"typeVersion":167},"e3ce9cdc-5484-4b4b-8701-6b9089a1f76d","setValueForMerge","n8n-nodes-base.set",[166,131],460,3.4,{"id":169,"name":170,"type":171,"position":172,"typeVersion":174},"0d49ec98-4806-492e-a6c2-a298ed8bb11a","Schedule Trigger","n8n-nodes-base.scheduleTrigger",[173,117],-1160,1.2,{},{"Is Exists":177,"Loop Over Items":184,"Schedule Trigger":190,"setValueForMerge":194,"Create New Merge Request":198,"Add Custom Notes To Merge Request":202,"API to CLOSE existing Merge Request":206,"API to Check existing merge request":210,"30 secs wait to approve merge request and pipeline to finish1":214},{"main":178},[179,182],[180],{"node":128,"type":181,"index":42},"main",[183],{"node":134,"type":181,"index":42},{"main":185},[186,188],[187],{"node":113,"type":181,"index":42},[189],{"node":141,"type":181,"index":42},{"main":191},[192],[193],{"node":113,"type":181,"index":42},{"main":195},[196],[197],{"node":158,"type":181,"index":42},{"main":199},[200],[201],{"node":147,"type":181,"index":42},{"main":203},[204],[205],{"node":151,"type":181,"index":42},{"main":207},[208],[209],{"node":134,"type":181,"index":42},{"main":211},[212],[213],{"node":121,"type":181,"index":42},{"main":215},[216],[217],{"node":163,"type":181,"index":42},[219,242,265],{"id":220,"name":221,"description":222,"pricing":223,"currency":224,"stripe_pricing":225,"is_active":27,"hosting":21,"revision_count":43,"tool_tips":226,"items":229,"created_dt":240,"last_updated_dt":241,"is_basic_package":21},"5258e380-032b-4394-a362-7fe9a81c8918","Customize","Template + tailored configuration",199,"USD",19900,{"title":227,"description":228},"Most popular choice","We'll configure the template for you -- adjusting prompts, keywords, and rules.",[230,232,234,236,238],{"text":231},"Complete workflow template",{"text":233},"Setup documentation",{"text":235},"Minor customization (prompts & configuration)",{"text":237},"Personalized keyword rules",{"text":239},"Priority email support","2025-12-14T14:56:53.877943Z","2025-12-14T14:56:53.878010Z",{"id":243,"name":244,"description":245,"pricing":246,"currency":224,"stripe_pricing":247,"is_active":27,"hosting":27,"revision_count":248,"tool_tips":249,"items":252,"created_dt":263,"last_updated_dt":264,"is_basic_package":21},"2bf66945-2e37-4ae8-a16c-3701198b0e25","Manage","2 rounds of revision, and hosting setup",499,49900,2,{"title":250,"description":251},"Hands-off solution","Complete setup and hosting. Includes 2 revision rounds plus a year of support.",[253,255,257,259,261],{"text":254},"Everything in Custom Setup",{"text":256},"2 rounds of revisions to tailor workflow to your needs",{"text":258},"Complete hosting setup",{"text":260},"Integration testing",{"text":262},"1 month warranty","2025-12-14T14:56:25.015547Z","2025-12-14T14:56:25.015580Z",{"id":266,"name":267,"description":268,"pricing":42,"currency":224,"stripe_pricing":42,"is_active":27,"hosting":21,"revision_count":42,"tool_tips":269,"items":272,"created_dt":277,"last_updated_dt":278,"is_basic_package":27},"f5dfbd54-5d04-4ae1-85ef-007db52e88f7","Workflow","Ready-to-use workflow template",{"title":270,"description":271},"Perfect for DIY users","Get the template and set it up yourself with our guide.",[273,274,275],{"text":231},{"text":233},{"text":276},"Community support","2025-12-14T14:55:49.328495Z","2025-12-14T14:55:49.328523Z",1776680497931]