Azure Pipeline Integration with SmartUI
Azure Pipelines is a cloud-based CI/CD service offered by Microsoft, part of the Azure DevOps suite. It helps automate the process of building, testing, and deploying applications to various platforms.
This guide explains how to integrate your project with the Azure CI/CD pipeline to trigger visual regression testing with LambdaTest SmartUI whenever changes are made to your repository.
Steps to Integrate Azure Pipeline with SmartUI
To integrate Azure 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: Set Up Your Repository
Ensure your project is hosted in Azure Repos, GitHub, or any supported repository.
Step 2: Create a New Pipeline:
- Navigate to Pipelines in your Azure DevOps project.
- Select New Pipeline and connect your repository.
Step 3: Add Environment Variables
Go to Pipeline Settings > Variables. Add the following variables:
LT_USERNAME: Your LambdaTest username.LT_ACCESS_KEY: Your LambdaTest access key.
Step 4: Setup your Workflow
trigger:
- '*'
variables:
LT_USERNAME: $(LT_USERNAME)
LT_ACCESS_KEY: $(LT_ACCESS_KEY)
jobs:
- job: SmartUI_Tests
pool:
vmImage: 'ubuntu-latest'
steps:
- task: UseNode@2
inputs:
version: '16.x'
- script: |
echo "Installing dependencies"
npm install @lambdatest/smartui-cli
displayName: 'Install Dependencies'
- script: |
echo "Running SmartUI tests"
npx smartui --version
npx smartui config:create smartui-web.json
npx smartui --config smartui-web.json exec -- mvn --quiet test -D suite=sdk-cloud.xml
displayName: 'Execute SmartUI Tests'
Step 5: 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 Azure Pipeline Variables for all sensitive data
- Mark variables as secret to hide values in logs
- 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:
trigger:
branches:
include:
- main
- develop
Build Naming
- Use meaningful build names that include branch/commit info
- Include commit SHA for traceability
- Use consistent naming conventions
Example:
variables:
BUILD_NAME: $(Build.SourceBranchName)-$(Build.SourceVersion)"
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 variables
Possible Causes:
- Variables not created in Azure DevOps
- Variable names don't match
- Variables not accessible to pipeline
- Variable scope issues
Solutions:
-
Verify variables exist in pipeline settings:
- Go to Pipelines → Edit → Variables
- Check
LT_USERNAME,LT_ACCESS_KEY, andPROJECT_TOKENexist
-
Ensure variable names match exactly (case-sensitive)
-
Check variable scope (pipeline, stage, or job level)
-
Verify variables are marked as secret if needed
Issue: PROJECT_TOKEN Not Available
Symptoms: Pipeline prompts for PROJECT_TOKEN or token not found
Possible Causes:
- PROJECT_TOKEN not set as pipeline variable
- Variable not passed to job
- Variable marked as secret incorrectly
Solutions:
-
Add PROJECT_TOKEN as Azure Pipeline Variable
-
Pass variable to job:
variables:
PROJECT_TOKEN: $(PROJECT_TOKEN) -
Check variable is accessible to the job
-
Verify variable scope includes your pipeline
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:
- task: PowerShell@2
displayName: 'Check Logs'
condition: failed()
inputs:
script: |
Get-Content $(Agent.TempDirectory)/*.log -
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:
timeoutInMinutes: 60 -
Run tests in parallel using matrix:
strategy:
matrix:
TestGroup1:
TEST_GROUP: 1
TestGroup2:
TEST_GROUP: 2 -
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:
- task: UseNode@2
inputs:
version: '18.x' -
Clear npm cache:
- script: |
npm cache clean --force
npm install -
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 installed
- npm not available
- PATH issues
Solutions:
-
Ensure Node.js setup task is included:
- task: UseNode@2
inputs:
version: '18.x' -
Verify npm is available:
- script: npm --version -
Install SmartUI CLI explicitly:
- script: |
npm install -g @lambdatest/smartui-cli
Getting Help
If you encounter issues not covered here:
- Review Azure Pipelines 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
