Technology

How to integrate Test Automation into the system pipeline with a downstream trigger on GitLab

This guide explains how to set up a downstream trigger to run automated tests after changes, ensuring quality before deployment.

How to integrate Test Automation into the system pipeline with a downstream trigger on GitLab

This guide will show you how to configure a downstream trigger to run automated tests in response to changes, ensuring quality before deployment. Follow these steps to streamline your testing process and improve the reliability of your code.


How to configure a Downstream trigger?

Before we start, consider that this configuration is for implementing the GitLab CI downstream to trigger from a Develop Merge Request on the STG environment. Now follow me, step by step!

1. Edit the .gitlab-ci.yml file

In the root directory of your team repository, edit or create a file named .gitlab-ci.yml. This file defines the stages and jobs for the CI/CD pipeline.

2. Add New Stages and Jobs

Below is a basic example of how to add a new stage to the .gitlab-ci.yml file:

In this example:

  • Stages – Define the sequence of stages (test, publish, vlad, integration_tests, rebuild-staging).
  • Job (integration_tests) – This job is placed in the integration_tests stage.
  • Rules – The job will be triggered if the commit tag matches the regex ^.\/stg\/.$ or if the commit branch matches the regex ^stg-.*$.
  • Trigger – It specifies the downstream project to trigger (projectName/repository).

3. Customize Job and Project Path

Add a job with the same stage name (integration_tests) and modify the trigger section to reflect your actual project path. 

4. Commit and Push: Commit the .gitlab-ci.yml file

5. Create a Merge Request

Merge Request: Create a new Merge Request (MR) on the project. This should trigger the pipeline and include the new integration_tests stage.

6. Monitor the Pipeline

CI/CD Section: Go to your GitLab project’s CI/CD section to monitor the pipeline’s progress. The pipeline will automatically run the stages according to the configuration in the .gitlab-ci.yml file.

7. Review Results

Review: Once the pipeline has been completed, review the test results within the GitLab interface. If any tests fail, you’ll be able to see detailed logs and reports to help diagnose and fix any issues.


How to integrate Test Automation into the system pipeline with a downstream trigger on GitLab: Additional Tips

  • Ensure the downstream project specified in the trigger section has appropriate permissions and is accessible from the current project.
  • Test your .gitlab-ci.yml changes in a feature branch before merging them into the main branch.
  • Use GitLab’s CI/CD pipeline editor to validate your .gitlab-ci.yml syntax and configuration.


How to integrate Test Automation into the system pipeline with a downstream trigger on GitLab: Final Thoughts Final Thoughts

By following all the steps described in this article, we will have our automated tests running in the Downstream GitLab pipeline. Thus, tests will always run after any new Merge Request, ensuring agility and constant testing, guaranteeing the quality of new application versions.

If you would like to know more about configuring a yaml for a test Pipeline, check this article.

Hope you enjoyed this guide and feel free to leave any questions in the comments.

Get In Orbit in your inbox

A monthly selection of articles and perspectives from KWAN. Choose what's relevant to you.

Related Articles

Beyond the Q1 Review: Why Your IT Outsourcing Model Might Be Compounding Risk
Technology

Beyond the Q1 Review: Why Your IT Outsou...

Discover why traditional IT outsourcing models may increase risk and learn how to build a sustainable, people-first arch...

Read article
Why Portugal Can Be Your Next Career Step
Technology

Why Portugal Can Be Your Next Career Ste...

As AI evolves, programmers must understand how to improve themselves and how to raise their values. This article explain...

Read article
How to prepare for a Certification in any Tech Career
Technology

How to prepare for a Certification in an...

As AI evolves, programmers must understand how to improve themselves and how to raise their values. This article explain...

Read article