Run a Sauce Connect Proxy service
Run Sauce Connect Proxy in a Background step in a Build stage.
In Harness CI, you use Background steps to manage services that need to run for the entire lifetime of a Build stage. To demonstrate how you can use Background steps, this topic explains how to run Sauce Connect Proxy in a Background step. Sauce Labs is a web and mobile application automated testing platform. Sauce Connect Proxy can run as a Background step in your Harness CI pipeline, and act as a proxy server between a Sauce Labs infrastructure and your CI pipeline.
Add a Background step
Create a Harness text secret containing a Sauce Labs Access Key. Make note of the secret's ID.
Create a Harness CI pipeline and add a Build stage.
You can disable clone codebase, because the pipeline created in this example doesn't need to pull any source code.
You can use Background steps with any build infrastructure. To follow along with this example, use either Harness Cloud build infrastructure or a Kubernetes cluster build infrastructure.
Add a Background step configured as follows:
Name: Enter a name, such as
sauce_connect.Container Registry: Select a Docker connector.
Image: Enter the name and tag of a Sauce Connect Docker image, such as
saucelabs/sauce-connect:latest.Environment Variables: Add two environment variables for your Sauce Labs credentials:
SAUCE_USERNAME: YOUR_SAUCE_LABS_USERNAMESAUCE_ACCESS_KEY: <+secrets.getValue('YOUR_SAUCE_ACCESS_KEY_SECRET_ID')>
Port Bindings: If you chose Harness Cloud build infrastructure, add port bindings
"8032": "8032". For more information, go to Background step settings - Port bindings.
Select Apply Changes to save the Background step.
Add a health check
Harness recommends adding health checks for Background steps. This example runs a cURL command to poll the readiness of the Sauce Connect service until it returns a successful response. This ensures that Sauce Connect is ready to receive traffic before the pipeline continues.
In your pipeline's Build stage, after the Background step, add a Run step configured as follows:
Name: Enter a name, such as
wait for SC.Container Registry and Image: With a Kubernetes cluster build infrastructure, select a Docker connector and enter the image
curlimages/curl:7.83.1. With Harness Cloud, these are not required because Harness Cloud runners already have the required cURL binary.Shell: Select Bash
Command: Enter the following:
Run the pipeline
Save the pipeline, select Run, and then select Run Pipeline.
While the build runs, you can observe the logs. When Sauce Connect is ready, the health check step prints SC ready.
YAML example
Here's the YAML for the Build stage created in this topic. A complete Harness CI pipeline would have additional steps after the Run step that build code, run tests, push images, and so on. Some or all of these steps might interact with the Sauce Labs Proxy service running in the background.
Last updated
Was this helpful?