Automate Your GitLab Merge Request Workflow
detail.loadingPreview
Streamline your GitLab merge request process with this n8n workflow. It intelligently checks for existing merge requests, creates new ones when needed, and automates merging when your pipeline succeeds. Boost your team's productivity and reduce manual overhead.
About This Workflow
This n8n workflow empowers development teams to automate repetitive tasks associated with GitLab merge requests. It begins by checking if an open merge request already exists for a given source branch. If not, it proceeds to create a new merge request with specified source and target branches, and a customizable title. The workflow can then optionally close existing merge requests and add custom notes. For seamless integration into your CI/CD pipeline, it includes a wait step before attempting to merge the request when the pipeline is successful, ensuring code quality before merging and optionally removing the source branch.
Key Features
- Intelligent Merge Request Check: Automatically detects if an open merge request already exists for a source branch.
- Automated Creation: Creates new merge requests with configurable source, target, title, and comments.
- Conditional Logic: Branches execution based on whether a merge request already exists.
- Pipeline-Driven Merging: Merges requests only after the pipeline succeeds and allows for automatic source branch removal.
- Customizable Notes: Add specific comments to merge requests.
How To Use
- Set up GitLab Credentials: Ensure your n8n instance has the necessary API credentials for GitLab configured.
- Configure Schedule Trigger: Set the
Schedule Triggernode to run your workflow at your desired intervals. - Check Existing Merge Request: In the
API to Check existing merge requestnode, replace<projectid>with your GitLab project ID and provide yoursourceBranchNameandgitlabTokenas variables. - Conditional Logic: The
Is Existsnode determines the workflow path. If no existing merge request is found, it proceeds to create a new one. - Create New Merge Request: Configure the
Create New Merge Requestnode with yoursourceBranchName,targetBranchName,mergeTitle, andgitlabToken. - Optional: Close Existing MRs: If you need to close outdated merge requests, configure the
API to CLOSE existing Merge Requestnode, ensuring you have the correctmerge_iidandgitlabToken. - Optional: Add Notes: Use the
Add Custom Notes To Merge Requestnode to add specific comments, providing yourmergeCommentsandmerge_iid. - Set Merge Options: Configure the
setValueForMergenode to definemerge_when_pipeline_succeeds(true/false) andshould_remove_source_branch(true/false). - Wait for Pipeline: The
30 secs wait to approve merge request and pipeline to finish1node introduces a delay. Adjust the duration as needed for your pipeline execution time. - Merge When Pipeline Succeeds: Finally, configure the
Merge When Pipeline Succeedsnode with yourmerge_iidandgitlabTokento automatically merge the request.
Apps Used
Workflow JSON
{
"id": "60167823-d87f-4a05-b2ad-27c81430f087",
"name": "Automate Your GitLab Merge Request Workflow",
"nodes": 6,
"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: 60167823-d87f...
About the Author
Crypto_Watcher
Web3 Developer
Automated trading bots and blockchain monitoring workflows.
Statistics
Related Workflows
Discover more workflows you might like
Automate Qualys Report Generation and Retrieval
Streamline your Qualys security reporting by automating the generation and retrieval of reports. This workflow ensures timely access to crucial security data without manual intervention.
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.
Robust Concurrency Control for n8n Workflows with Redis
Prevent simultaneous execution of critical n8n workflows or tasks using a centralized, Redis-backed locking mechanism. This reusable utility workflow ensures data integrity and resource management by allowing other workflows to acquire, check, and release locks.