CI pipeline creation overview
This topic provides an overview of CI pipeline creation and configuration, including common components, such as Build stages, steps, and codebases, as well as advanced settings.
For definitions of terms like stage, step, build infrastructure, delegate, connector, and so on, go to CI pipeline components.
A CI pipeline is an end-to-end integration workflow that, in its simplest form, pulls a codebase, builds an artifact, and then uploads the artifact to storage or a registry such as Docker Hub, Google Cloud Registry, JFrog Artifactory, and many others. Pipelines are comprised of stages and steps.
You can run a pipeline manually or set up triggers to automatically run it on a schedule or when an event occurs, such as a Git merge in your codebase.
Create a pipeline in Harness CI
- In the Builds (Continuous Integration) modules, select Pipelines, and then select Create a Pipeline.
- Enter a Name for the pipeline. Description and Tags are optional.
- Select Inline to store your pipeline configuration in Harness, or select Remote to store your pipeline as code in a Git repository.
- If you want to use a pipeline template, select Start with Template.
- Select Start.
You can now add stages and steps to the pipeline, as well as configure pipeline settings. For a guided experience, try one of the CI tutorials.
You can also import pipelines from Git.
In addition to a default codebase, the following settings are configurable at the pipeline level:
- Input sets and overlays
- Flow Control: Synchronization barriers
- Policy Sets
- Advanced Options: Pipeline Timeout Settings, Stage Execution Settings, and Delegate Selectors
Harness Input Sets are collections of runtime inputs for a pipeline run. Overlays are groups of Input Sets. Use Overlays to provide multiple Input Sets when you run a pipeline.
With Input Sets and Overlays, you can use the same pipeline for multiple scenarios. You can define each scenario in an Input Set or Overlay, and then select the appropriate scenario at runtime.
A CI stage is a subset of a pipeline that contains one major segment of the CI workflow. All stages have stage settings and one or more steps.
To add a stage to a pipeline, select Add Stage in the Pipeline Studio. The most essential stage for CI pipelines is the Build stage, which includes steps that test code, build and push images, and upload artifacts, among other steps.
CI Build stage settings include codebase configuration, build infrastructure, shared paths, and other advanced settings.
To make pipelines more versatile, you can create templates, use stage variables, and create custom stages, among other optimization techniques.
CI pipelines build and test code that is pulled from a Git code repository. When you add a Build stage to a CI pipeline, you specify the Git account and repository where your code is stored. The codebase declared in the first stage in a pipeline becomes the pipeline's default codebase. You can use this codebase for later stages in the pipeline, or you can use multiple codebases in the same pipeline. For more information, go to Configure codebases.
Harness uses code repo connectors to connect to Git repositories.
All stages have an infrastructure definition, which represents the build infrastructure used by a CI pipeline: the target clusters, hosts, and so on. Build infrastructure components and specifications depend on the build infrastructure you choose. For more information, go to Which build infrastructure is right for me?.
You can use Shared Paths in a stage to share data across steps or customize cache paths for Cache Intelligence.
When a pipeline runs, it creates a temporary volume called a workspace. During initialization, the stage clones your codebase to the root of the workspace. Then, the steps in the stage run inside the root. The workspace is the current working directory for each step in the stage. The workspace persists for the lifetime of the stage and enables steps in that stage to communicate and share state information. The default shared working directory for a stage is
/harness. The workspace is destroyed when the stage ends.
Individual steps can communicate and share state using the workspace filesystem. The workspace is a volume, so filesystem changes persist throughout the stage lifetime. If you need to share additional volumes, you can add Shared Paths. Paths must begin with a forward slash, such as
For example, the maven
m2 repo is stored in
/root/.m2 by default. If your Build stage uses Maven, you can specify
/root/.m2 as a Shared Path so that all steps in that stage can access that directory.
A stage contains one or more steps. Each step is a series of commands that perform a task. For example, A Build and Push step builds an image and pushes it to a cloud repo, a Run step runs a series of shell commands, and so on. Go to the following documentation for details about how you can use the various CI steps in your pipelines:
- Build and upload artifacts
- Run tests
- Manage dependencies
- Share and cache CI data
- Run scripts
- Use plugins
- Security step (Harness STO)
Advanced stage and step settings
Stages and steps have advanced settings to control the flow of operations.
Use conditional execution settings to specify when a stage or step should run. For example, you can specify that a particular stage should run only if the prior pipeline or stage failed.
You can specify conditional execution settings for an entire stage and for individual steps. A stage's conditional execution settings apply to all steps in that stage that don't have their own step-level conditional execution settings. A step's conditional execution settings overrides the stage's conditional execution settings.
For information about looping strategies to go:
Failure strategies define how your stages and steps handle different failure conditions.
Each failure strategy is comprised of the following:
- Error conditions that trigger the failure strategy.
- Actions to take when the specified error conditions occur.
Failure strategies are a critical pipeline design component that determine what causes a stage or step to fail and what to do when a failure occurs.