Background step settings
Use Background steps to manage dependent services that need to run for the entire lifetime of a Build stage. For example, you can set up your pipeline to run multiple background services that implement a local, multi-service app.
A Background step starts a service and then proceeds. For any later step that relies on the service, it is good practice to verify that the service is running before sending requests.
- Background steps do not support failure strategies or output variables.
- If the pipeline runs on a VM build infrastructure, you can run the background service directly on the VM rather than in a container. To do this, leave the Container Registry and Image fields blank.
- Depending on the stage's build infrastructure, some settings might be unavailable, optional, or located under Additional Configuration.
Name and Id
Enter a name summarizing the step's purpose. Harness automatically assigns an Id (Entity Identifier Reference) based on the Name. You can change the Id until the step is saved; once saved, the Id is locked.
If you are using a VM, local runner, or the Harness Cloud build infrastructure where the background step is running a container, you can use the Background step Id to call services started by Background steps in later steps, such as commands in Run steps. For example, a cURL command could call BackgroundStepId:5000
where it might otherwise call localhost:5000
.
pythonscript
, is used in a cURL command in a Run step.If the Background step is inside a step group, you must include step group ID, such as curl StepGroupId_BackgroundStepId:5000
, even if both steps are in the same step group.
If the Background step runs directly on the host or in a Kubernetes cluster build infrastructure, do not use the step ID to reference Background steps. Instead, use localhost:host_port
. For Background steps running MySQL in a Kubernetes cluster build infrastructure, you must use the IP and host port, such as 127.0.0.1:7001
. For more information, go to Port Bindings.
Container Registry and Image
Container Registry is a Harness container registry connector that connects to the container registry, such as Docker Hub, from which you want Harness to pull an image.
Image is the container image to use for the background service. The image name should include the tag, or it defaults to the latest
tag if unspecified. You can use any Docker image from any Docker registry, including Docker images from private registries. Different container registries require different name formats:
- Docker Registry: Input the name of the artifact you want to deploy, such as
library/tomcat
. Wildcards aren't supported. FQN is required for images in private container registries. - ECR: Input the FQN (fully-qualified name) of the artifact you want to deploy. Images in repos must reference a path, for example:
40000005317.dkr.ecr.us-east-1.amazonaws.com/todolist:0.2
. - GCR: Input the FQN (fully-qualified name) of the artifact you want to deploy. Images in repos must reference a path starting with the project ID that the artifact is in, for example:
us.gcr.io/playground-243019/quickstart-image:latest
.
The stage's build infrastructure determines whether these fields are required or optional:
- Kubernetes cluster build infrastructure: Container Registry and Image are always required.
- Local runner build infrastructure: Background steps can use binaries available on the host machine. The Container Registry and Image are required if the machine doesn't have the binaries you need.
- Self-hosted cloud provider VM build infrastructure: Background steps can use binaries that you've made available on your build VMs. The Container Registry and Image are required if the VM doesn't have the necessary binaries. These fields are located under Optional Configuration for stages that use self-hosted VM build infrastructure.
- Harness Cloud build infrastructure: Background steps can use binaries available on Harness Cloud machines, as described in the image specifications. The Container Registry and Image are required if the machine doesn't have the binary you need. These fields are located under Optional Configuration for stages that use Harness Cloud build infrastructure.