Background step settings
Use Background steps to manage dependent services.
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.
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.
Container Registry and Image
The build environment must have the necessary binaries for the Background step to execute your test commands. Depending on the stage's build infrastructure, Background steps can use binaries that exist in the build environment, or use Container Registry and Image to pull an image, such as a public or private Docker image, that contains the required binaries.
Shell, Entry Point, and Command
Use these fields to define the commands that you need to run in the Background step.
Shell
Select the shell type for the commands defined in Entry Point or Command. Options include: Bash, PowerShell, Pwsh (PowerShell Core), Sh, and Python. If the step includes commands that aren't supported for the selected shell type, the build fails. Required binaries must be available on the build machine or through a specified Container Registry and Image.
Entry Point
Supply a list of arguments in exec format. Entry Point arguments override the image ENTRYPOINT and any commands in the Command field. Enter each argument separately.
If you want to add your Entry Point arguments to the image ENTRYPOINT, include both the image ENTRYPOINT, such as dockerd-entrypoint.sh, and your additional arguments in Entry Point.
Command
Enter POSIX shell script commands (beyond the image ENTRYPOINT) for this step. If the step runs in a container, the commands are executed inside the container.
This Bash script example checks the Java version.
This is a simple PowerShell Wait-Event example.
This PowerShell Core example runs ForEach-Object over a list of events.
In this example, the pulls a python image and executes a shell script (Sh) that runs pytest with code coverage.
If the shell is Python, supply Python commands directly in command.
This example uses a basic print command.
Privileged
Select this option to run the container with escalated privileges. This is the equivalent of running a container with the Docker --privileged flag.
Report Paths
The path to the files that store results in JUnit XML format. You can add multiple paths. If you specify multiple paths, make sure the files contain unique tests to avoid duplicates. Glob is supported.
This setting is required for commands run in the Background step to be able to publish test results.
Environment Variables
You can inject environment variables into the step container and use them in the Command script. You must input a Name and Value for each variable.
You can reference environment variables in the Command script by name. For example, a Bash script would use $var_name or ${var_name}, and a Windows PowerShell script would use $Env:varName.
Variable values can be fixed values, runtime inputs, or expressions. For example, if the value type is expression, you can input a value that references the value of some other setting in the stage or pipeline.
Image Pull Policy
If the service is running in a container, you can select an option to set the pull policy for the image.
Always: The kubelet queries the container image registry to resolve the name to an image digest every time the kubelet launches a container. If the kubelet encounters an exact digest cached locally, it uses its cached image; otherwise, the kubelet downloads (pulls) the image with the resolved digest, and uses that image to launch the container.
If Not Present: The image is pulled only if it is not already present locally.
Never: The image is assumed to exist locally. No attempt is made to pull the image.
Port Bindings
The host port and container port binding are similar to port mapping in Docker. Usually the ports are the same unless the default host port for the Background step is already in use by another local service or you are running multiple instances of the same service.
Depending on the Build stage's Infrastructure, some steps might run directly on VMs while other steps run in containers. The port used to communicate with a service started by a Background step depends on where the step is running. For example, assume you create a Background step with the Name and ID myloginservice. To call this service in later steps in the same stage, you use:
myloginservice:container_portfor containerized steps, such as those running in self-managed VM build infrastructures or running Docker images.localhost:host_postfor steps running in a Kubernetes cluster build infrastructure or directly on the build machine (such as a service running from a binary already installed on the host machine). For steps running MySQL in a Kubernetes cluster build infrastructure, you must use127.0.0.1:host_port.
Run as User
If the service is running in a container, you can specify the user ID to use for all processes in the pod. For more information about how to set the value, go to Set the security context for a pod.
Set Container Resources
The maximum memory and cores that the container can use.
Limit Memory: The maximum memory that the container can use. You can express memory as a plain integer or as a fixed-point number using the suffixes
GorM. You can also use the power-of-two equivalentsGiandMi. Do not include spaces when entering a fixed value. The default value is500Mi.Limit CPU: The maximum number of cores that the container can use. CPU limits are measured in CPU units. Fractional requests are allowed; for example, you can specify one hundred millicpu as
0.1or100m. The default is400m. For more information, go to Resource units in Kubernetes.
Troubleshoot Background steps
Go to the CI Knowledge Base for questions and issues related to Background steps, including:
Last updated
Was this helpful?