GitLab Pipeline Integration with SmartUI
A GitLab Pipeline automates building, testing, and deploying code changes. It's essential for rapid development, improved code quality, and faster delivery by catching errors early and reducing manual work.
This document will show you how to integrate GitLab Pipeline with SmartUI to shorten your test cycles.
Steps to Integrate GitLab Pipeline with SmartUI
To integrate GitLab Pipeline with SmartUI, 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 LambdaTest GitHub repository to run the tests on the SmartUI.
Step 1: Setup your Projects in GitLab
- Click on the New Project > Run CI/CD for external repository.
- Enter your repository URL and click on Create Project.
Step 2: Create a New Workflow
- Navigate to the Build section > Pipelines.
- Select your required template for CI/CD workflow file. For the demo we are using the Test template.
- Now, write your workflow YAML file. Here is the sample file for your reference.
- Commit this yaml file in your repository and make the required changes in your code to automatically trigger the pipeline.
loading...
You can also store your LT_USERNAME, LT_ACCESS_KEY and PROJECT_TOKEN as secrets in your GitLab project repository.
Step 3: Check the output
- After triggering the workflow, check your results in the SmartUI Dashboard
Best Practices
- Secret Management
- Pipeline Optimization
- Build Naming
- Error Handling
- Resource Management
- Resource Management
Secret Management
- Never commit credentials to repository
- Use GitLab CI/CD Variables for all sensitive data
- Rotate secrets regularly
- Use different secrets for different environments
Pipeline Optimization
- Use parallel jobs for faster execution
- Cache dependencies to speed up pipelines
- Only run visual tests on relevant branches
- Set up pipeline conditions to avoid unnecessary runs
Example:
only:
- main
- develop
- merge_requests
Build Naming
- Use meaningful build names that include branch/commit info
- Include commit SHA for traceability
- Use consistent naming conventions
Example:
variables:
BUILD_NAME: MR-$CI_MERGE_REQUEST_IID-$CI_COMMIT_SHORT_SHA"
Error Handling
- Set up proper error handling in pipelines
- Use pipeline status checks
- Configure notifications for failures
- Add retry logic for flaky tests
Resource Management
- Limit concurrent pipeline runs
- Clean up old builds regularly
- Monitor pipeline execution time
- Optimize test execution order
Resource Management
- Limit concurrent pipeline runs
- Clean up old builds regularly
- Monitor pipeline execution time
- Optimize test execution order
Troubleshooting
- Pipeline Fails with Variable Not Found
- PROJECT_TOKEN Not Available
- Tests Run But No Results in Dashboard
- Pipeline Times Out
- Dependencies Installation Fails
- SmartUI CLI Not Found
Issue: Pipeline Fails with "Variable Not Found"
Symptoms: Pipeline fails with error about missing CI/CD variables
Possible Causes:
- Variables not created in GitLab project
- Variable names don't match
- Variables not accessible to pipeline
Solutions:
-
Verify variables exist in project settings:
- Go to Settings → CI/CD → Variables
- Check
LT_USERNAME,LT_ACCESS_KEY, andPROJECT_TOKENexist
-
Ensure variable names match exactly (case-sensitive)
-
Check variable scope (project, group, or instance level)
-
Verify variables are not protected if needed for protected branches
Issue: PROJECT_TOKEN Not Available
Symptoms: Pipeline prompts for PROJECT_TOKEN or token not found
Possible Causes:
- PROJECT_TOKEN not set as CI/CD variable
- Variable not passed to job
- Variable masked or protected incorrectly
Solutions:
-
Add PROJECT_TOKEN as GitLab CI/CD Variable
-
Pass variable to job:
variables:
PROJECT_TOKEN: $PROJECT_TOKEN -
Check variable is not masked if you need to see it in logs
-
Verify variable scope includes your branch
Issue: Tests Run But No Results in Dashboard
Symptoms: Pipeline completes but screenshots don't appear in SmartUI
Possible Causes:
- Incorrect PROJECT_TOKEN
- Project name mismatch
- Network issues
- Pipeline job failure
Solutions:
-
Verify PROJECT_TOKEN is correct:
- Check token in SmartUI Project Settings
- Ensure token includes project ID prefix
-
Check pipeline logs for errors:
after_script:
- if [ $CI_JOB_STATUS == 'failed' ]; then cat job.log; fi -
Verify network connectivity in pipeline
-
Check if SmartUI CLI step completed successfully
Issue: Pipeline Times Out
Symptoms: Pipeline execution exceeds time limit
Possible Causes:
- Too many tests running
- Slow test execution
- Network latency
- Resource constraints
Solutions:
-
Increase pipeline timeout:
default:
timeout: 1h -
Run tests in parallel using parallel jobs:
parallel:
matrix:
- TEST_GROUP: [1, 2, 3] -
Optimize test execution
-
Split tests across multiple pipeline stages
Issue: Dependencies Installation Fails
Symptoms: npm install or dependency installation fails
Possible Causes:
- Network issues
- Package registry problems
- Version conflicts
- Node version mismatch
Solutions:
-
Use specific Node version:
image: node:18 -
Clear npm cache:
before_script:
- npm cache clean --force -
Use package-lock.json for consistent installs
-
Check for version conflicts in package.json
Issue: SmartUI CLI Not Found
Symptoms: npx smartui command fails with command not found"
Possible Causes:
- Node.js not available in image
- npm not available
- PATH issues
Solutions:
-
Ensure Node.js is available:
image: node:18 -
Verify npm is available:
before_script:
- npm --version -
Install SmartUI CLI explicitly:
before_script:
- npm install -g @lambdatest/smartui-cli
Getting Help
If you encounter issues not covered here:
- Review GitLab CI/CD Documentation
- Check SmartUI CLI Documentation for CLI-specific issues
- Visit LambdaTest Support for additional resources
- Contact support at support@lambdatest.com or use 24/7 Chat Support
