GitLab Integration with HyperExecute
GitLab is a web-based Git repository that provides free open and private repositories, issue-following capabilities, and wikis. It is a complete DevOps platform that enables professionals to perform all the tasks in a project, from project planning and source code management to monitoring and security.
This document will show you how to integrate GitLab Pipeline with HyperExecute to greatly shorten your test cycles.
How To Integrate GitLab Pipeline with HyperExecute
To integrate GitLab Pipeline with HyperExecute, follow the below steps:
You can use your own project to configure and test it. For demo purposes, we are using the sample repository.
Download or Clone the code sample from the TestMu AI GitHub repository to run the tests on the HyperExecute.
1. Log into your GitLab account
2. Create a New Project
To create a new project and connect your external repository to GitLab CI/CD, click the Run CI/CD for external repository tab on the bottom right.
3. Connect Your External Repository:
On GitLab, you can either connect your external repository from GitHub or by URL. In this example, we will connect our external repository by URL.
To connect your external repository by URL, fill in the required information in the form below and click the Create Project button at the bottom of the page.
4. Add Your Credentials as CI/CD Variables
Keep your TestMu AI username and access key out of the pipeline file. Store them as project variables, and the pipeline reads them at run time.
- In your GitLab project, go to Settings > CI/CD, expand Variables, and click Add variable. You need the Maintainer role.
- Add a variable with the key
LT_USERNAMEand your TestMu AI username as the value. - Add a variable with the key
LT_ACCESS_KEYand your TestMu AI access key as the value. - Keep the visibility of both variables at Masked, the default, so GitLab shows
[MASKED]in job logs instead of the value. GitLab can mask a value only when it is a single line with no spaces and at least 8 characters long. If your username is shorter than 8 characters, setLT_USERNAMEto Visible and keepLT_ACCESS_KEYmasked. - If you also select Protect variable, the variables are passed only to pipelines that run on protected branches or tags, such as your default branch.
To find your username and access key, see how to get your username and access key.
5. Configure the Pipeline
- To configure the new pipeline that you just created, click the Configure Pipeline button in the center of the page.
- Click on the +Set up CI/CD button as shown below.
- Create a new
.gitlab-ci.ymlfile at the root of the repository.
Below is a sample of GitLab YAML created for your reference:
Verifiedstages:
- test
hyperexecute:
stage: test
image: ubuntu:latest
rules:
# Run on the default branch (adjust as needed)
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
before_script:
# ubuntu:latest does not ship curl, so install it first
- apt-get update && apt-get install -y curl ca-certificates
# Download the Linux HyperExecute CLI and make it executable
- curl -fsSL https://downloads.lambdatest.com/hyperexecute/linux/hyperexecute -o hyperexecute
- chmod +x hyperexecute
script:
# LT_USERNAME and LT_ACCESS_KEY come from the masked CI/CD variables added in step 4
# Replace <your_yaml_file_path> with the path of your HyperExecute YAML file
- ./hyperexecute --user "$LT_USERNAME" --key "$LT_ACCESS_KEY" --config <your_yaml_file_path>
- stages: Lists the stages of the pipeline. This example has one stage,
test. - hyperexecute: The job that runs your tests. It runs in the
teststage on theubuntu:latestimage. - rules: Runs the job on pushes to the default branch. Change the condition to run it on other branches or on merge requests.
- before_script: Installs curl, downloads the Linux build of the HyperExecute CLI and makes it executable.
- script: Runs the HyperExecute CLI with your TestMu AI username and access key, read from the masked variables, and the path of the YAML file created for HyperExecute. For every flag the CLI accepts, see the HyperExecute CLI guide.
6. Run Your Job
- To commit your changes and run your job, click the Commit Changes button.
Below is an example of a HyperExecute job that was triggered through the above pipeline:
Run your tests at speeds never seen before. Happy testing! :)