Automated GitLab Merge Request Creation and Management
detail.loadingPreview
Streamline your GitLab workflow with this n8n automation that intelligently manages merge requests. It checks for existing open MRs, creates new ones with custom notes if none are found, and can even close outdated ones to maintain a clean and efficient development pipeline.
About This Workflow
This n8n workflow provides a robust solution for automating your GitLab merge request processes. Triggered on a schedule, it first queries GitLab to identify any open merge requests originating from a specified source branch. If existing open MRs are detected, the workflow proceeds to close them, ensuring that only current and relevant merge requests are active. Conversely, if no open MRs are found for the branch, it automatically creates a new one, populates it with a custom title and notes, and configures options like source branch removal. This automation drastically reduces manual overhead and helps enforce consistent branching strategies for development teams.
Key Features
- Scheduled Execution: Automate your merge request management to run at specified intervals, ensuring continuous oversight.
- Duplicate MR Handling: Intelligently checks for existing open merge requests from the same source branch and can close them, preventing clutter.
- Automated MR Creation: Creates new merge requests with predefined source/target branches and custom titles when no active ones exist.
- Custom Notes & Descriptions: Automatically adds custom notes to newly created merge requests for improved communication and context.
- Configurable Merge Options: Set parameters like automatically removing the source branch after a successful merge or enabling 'merge when pipeline succeeds'.
How To Use
- Set Your Schedule: Configure the
Schedule Triggernode to define how often this workflow should run (e.g., daily, hourly, or custom cron expression). - GitLab Credentials & Project ID: Replace
<projectid>in allHTTP Requestnode URLs with your actual GitLab project ID. Provide yourgitlabToken(a GitLab Private Access Token withapiscope) as an expression in thePRIVATE-TOKENheader parameter for all API calls. - Define Merge Request Details: Configure input parameters for
sourceBranchName,targetBranchName,mergeTitle, andmergeCommentsto dynamically control your merge request details via expressions. - Review Merge Options: In the
setValueForMergenode, adjustmerge_when_pipeline_succeeds(default isfalse, set totrueto enable automatic merge upon pipeline success) andshould_remove_source_branchas per your team's policy. - Optional Wait Time: Customize the
30 secs wait to approve merge request and pipeline to finish1node's duration if needed, or remove it if not required for your specific approval or pipeline process.
Apps Used
Workflow JSON
{
"id": "6e713c41-94a4-4cd8-a4c7-5c6c95152c46",
"name": "Automated GitLab Merge Request Creation and Management",
"nodes": 10,
"category": "DevOps",
"status": "active",
"version": "1.0.0"
}Note: This is a sample preview. The full workflow JSON contains node configurations, credentials placeholders, and execution logic.
Get This Workflow
ID: 6e713c41-94a4...
About the Author
AI_Workflow_Bot
LLM Specialist
Building complex chains with OpenAI, Claude, and LangChain.
Statistics
Related Workflows
Discover more workflows you might like
Visualize Your n8n Workflows: Interactive Dashboard with Mermaid.js
Gain unparalleled visibility into your n8n automation landscape. This workflow transforms your n8n instance into a dynamic, interactive dashboard, leveraging Mermaid.js to visualize all your workflows in one accessible place.
Effortless Bug Reporting: Slack Slash Command to Linear Issue
Streamline your bug reporting process by instantly creating Linear issues directly from Slack using a simple slash command. This workflow enhances team collaboration by providing immediate feedback and a structured approach to logging defects, saving valuable time for development and QA teams.
Automated PR Merged QA Notifications
Streamline your QA process with this automated workflow that notifies your team upon successful Pull Request merges. Leverage AI and vector stores to enrich notifications and ensure seamless integration into your development pipeline.