Buildkite Pipeline Integration with SmartUI
Buildkite is a hybrid CI/CD platform that allows you to run builds in your own infrastructure, alongside cloud-based execution. This means you can leverage the power of your existing machines or cloud resources to run builds.
This guide explains how to integrate your project with the Buildkite CI/CD pipeline to trigger visual regression testing with LambdaTest SmartUI whenever changes are made to your repository.
Steps to Integrate Buildkite Pipeline with SmartUI
To integrate Buildkite 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 GitHub, or any supported repository.
Step 2: Create a New Pipeline:
- Navigate to Pipelines in your Buildkite 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
steps:
- label: "SmartUI Tests"
agents:
queue: "default"
env:
LT_USERNAME: "${LT_USERNAME}"
LT_ACCESS_KEY: "${LT_ACCESS_KEY}"
commands:
- echo "Checking out code"
- git clone <REPO_URL>
- cd <PROJECT_DIRECTORY>
- echo "Installing SmartUI CLI"
- npm install @lambdatest/smartui-cli
- 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
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 Buildkite Environment 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 steps 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:
branches: main develop"
Build Naming
- Use meaningful build names that include branch/commit info
- Include commit SHA for traceability
- Use consistent naming conventions
Example:
env:
BUILD_NAME: ${BUILDKITE_BRANCH}-${BUILDKITE_COMMIT:0:7}"
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 environment variables
Possible Causes:
- Variables not created in Buildkite project
- Variable names don't match
- Variables not accessible to pipeline
- Variable scope issues
Solutions:
-
Verify variables exist in project settings:
- Go to Project Settings → Environment Variables
- Check
LT_USERNAME,LT_ACCESS_KEY, andPROJECT_TOKENexist
-
Ensure variable names match exactly (case-sensitive)
-
Check variable scope (pipeline or organization 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 environment variable
- Variable not passed to step
- Variable masked incorrectly
Solutions:
-
Add PROJECT_TOKEN as Buildkite Environment Variable
-
Pass variable to step:
env:
PROJECT_TOKEN: ${PROJECT_TOKEN}" -
Check variable is accessible to the pipeline
-
Verify variable scope includes your project
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 step failure
Solutions:
-
Verify PROJECT_TOKEN is correct:
- Check token in SmartUI Project Settings
- Ensure token includes project ID prefix
-
Check pipeline logs for errors:
- label: Check Logs"
if: "build.state == 'failed'"
commands:
- cat /tmp/*.log || true -
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 in Buildkite settings
-
Run tests in parallel using parallel steps:
- wait
- parallel:
- label: Test Group 1"
commands:
- npx smartui exec -- <command>
- label: "Test Group 2"
commands:
- npx smartui exec -- <command> -
Optimize test execution
-
Split tests across multiple pipeline steps
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:
commands:
- nvm use 18 -
Clear npm cache:
commands:
- 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 is available:
commands:
- nvm use 18 -
Verify npm is available:
commands:
- npm --version -
Install SmartUI CLI explicitly:
commands:
- npm install -g @lambdatest/smartui-cli
Getting Help
If you encounter issues not covered here:
- Review Buildkite 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
