Use this powerful n8n workflow to automate checking, creating, closing, commenting on, and merging GitLab Merge Requests (MRs) directly using the HTTP Request n8n node.
Download this n8n workflow template and start using it instantly.
DevOps Engineers looking to streamline deployment pipelines.
Technical leads who need reliable, scheduled code deployment automation.
Users seeking advanced examples of how to integrate third-party APIs using the n8n node.
Anyone wanting to convert manual GitLab steps into a robust, scheduled n8n trigger.
Managing Merge Requests (MRs) manually can be tedious and prone to human error, especially in continuous integration environments. This n8n workflow solves this by providing a complete, automated MR lifecycle management system directly integrated with the GitLab API.
Starting with a simple n8n trigger, the automation checks if a specific MR already exists. If it finds one or more, it automatically closes them via an iterative loop, ensuring a clean slate. It then creates a new MR, adds necessary custom notes for context, waits for the pipeline to initiate, and finally executes the merge action, optionally removing the source branch. This powerful approach demonstrates how specialized n8n templates can manage complex DevOps operations reliably.
The entire process is controlled by a scheduled n8n trigger and executes the following steps:
sourceBranchName.Split In Batches n8n node iterates over them. A subsequent HTTP Request n8n node uses a PUT command to explicitly set the stateevent to close for each existing MR.) to the newly created Merge Request.shouldremovesourcebranch: true.To deploy this n8n workflow, follow these steps:
api scope., sourceBranchName, targetBranchName, mergeTitle, gitlabToken, mergeComments, and ) within the HTTP Request n8n node expressions. These values must be replaced with static strings or references to incoming data/Set n8n nodes if you modify the trigger. Schedule Trigger (n8n trigger): Initiates the entire automation on a set schedule.
API to Check existing merge request (HTTP Request n8n node): Sends a GET request to the GitLab Merge Request API, filtering by state: opened and a specific sourcebranch. Crucial for deciding the flow path.
Is Exists (If n8n node): Implements the core flow control, directing the n8n workflow based on whether existing open MRs were found. It uses the isEmpty() expression.
Loop Over Items (Split In Batches n8n node): Manages iteration when multiple existing Merge Requests must be closed.
API to CLOSE existing Merge Request (HTTP Request n8n node): Uses a PUT request to update the MR state to 'close'. Essential for cleanup in this n8n template.
Create New Merge Request (HTTP Request n8n node): Uses a POST request with URL-encoded body parameters (sourcebranch, targetbranch, title) to initiate the new MR.
Add Custom Notes To Merge Request (HTTP Request n8n node): Posts a comment/note to the MR using the internal merge request ID ().
30 secs wait... (Wait n8n node): Pauses the n8n workflow execution flow for a specific duration (30 seconds) before attempting the final merge.
setValueForMerge (Set n8n node): Standardizes the input data for the final merge step, defining parameters like shouldremovesource_branch.
Merge When Pipeline Succeeds (HTTP Request n8n node): The final action. Sends a PUT request with a JSON body to execute the merge operation on the GitLab server, finalizing the goal of this n8n template.
Use this powerful n8n workflow to automatically scrape GitHub's daily, weekly, and monthly trending repositories using Firecrawl, extract key data with an AI Agent, and sync it directly to Supabase.

Use this powerful n8n workflow to automatically create GitHub Pull Requests and update JIRA task statuses directly from specified commands embedded within your Git commit messages.

Use this powerful n8n workflow to automatically lint, fix, and create new Pull Requests on GitHub using a Google Gemini AI Agent. Leverage n8n templates for streamlined DevOps automation.

Automate Gmail inbox management using this powerful n8n workflow. GPT-4o reasons through incoming emails and assigns relevant labels automatically using a dedicated n8n node.

Implement the Eisenhower Matrix automatically in Gmail using this powerful n8n workflow template. Prioritize and label incoming emails as Urgent/Important with GPT-4, significantly reducing inbox clutter.









































