Skip to main content

Create your first pipeline

Last updated on

This quickstart walks you through creating and running your first Harness pipeline using the Pipeline Studio.

This topic uses a Custom stage with a Shell Script step. A Custom stage does not require build infrastructure or deployment prerequisites, allowing you to focus on creating and running the pipeline.

After completing this quickstart, you can add CI Build stages, CD Deploy stages, or any other stage type.


What you will learn from this topic


Before you begin

  • Harness account: You need an active Harness account. If you do not have one, sign up for free.
  • Project: You need an existing project. For more information, refer to Organizations and Projects.
  • Permissions: You need the Pipeline: Create/Edit permission in the project. For more information, refer to RBAC in Harness.
  • Delegate: A Harness Delegate is required to execute steps on your infrastructure. If you do not have a delegate yet, go to Install a delegate to install one.

Pipeline creation architecture

You create and manage pipelines in a Harness project. If you are new to Harness pipelines, use this flow to get started:

The exact configuration depends on what you want the pipeline to do and which Harness module you are using.

Pipeline studio modes

Harness Pipeline Studio provides two interchangeable editors. To switch between editors, use the Visual / YAML toggle at the top of Pipeline Studio.

Switch between Visual and YAML editors in Pipeline Studio

Visual

The Visual editor is a graphical canvas where you configure stages and steps using the Harness UI. It is the recommended starting point for new pipeline authors.

Key areas in the visual editor:

  • Pipeline canvas: Shows stages as cards arranged left to right. Select a stage to open its configuration panel.
  • Stage configuration panel: Contains the Overview, Infrastructure, Execution, and Advanced tabs for the selected stage.
  • Step Library: A searchable catalog of available steps. Open it by selecting Add Step in a stage's execution view.
  • Pipeline header: Contains Run, Save, Triggers, Input Sets, Variables, and Notifications controls.
Pipeline visual mode

Create a pipeline

This section demonstrates how to create a pipeline with a Custom stage and a Shell Script step using the visual editor. The same workflow applies when you create pipelines with other stage types and steps.

Perform the following steps to create a pipeline.

  1. In Harness, navigate to your project.

  2. In the left navigation, select Pipelines.

  3. Select + Create a Pipeline.

  4. In the Create new Pipeline dialog, enter a Name for your pipeline. For this quickstart, enter DemoPipeline.

    Harness automatically generates an ID from the name. You can edit the ID now; after saving, the ID cannot be changed.

  5. Choose where to store the pipeline definition:

    • Select Inline to store the pipeline configuration in Harness.
    • Select Remote to store it as code in a Git repository. For more information, refer to Git Experience.
  6. Select Start.

Create new Pipeline dialog showing the Name field, Inline and Remote storage options, and the Start button

Harness opens Pipeline Studio in the visual editor.

YAML

You can also create this pipeline using the YAML editor by replacing the default YAML with the following definition:

pipeline:
name: DemoPipeline # Enter the pipeline name.
identifier: DemoPipeline # Pipeline ID. Harness generates this from the name.
tags: {} # Optional: Add pipeline tags.
projectIdentifier: KrishnamoorthyTest # Project where the pipeline is created.
orgIdentifier: default # Organization that contains the project.

Add a Custom stage

Perform the following steps to add a Custom stage to the pipeline.

  1. On the pipeline canvas, select Add Stage.

  2. Select Custom Stage as the stage type.

    tip

    To create a CI build pipeline instead, select Build and go to Get started with Harness CI. To create a CD deployment pipeline, select Deploy and go to Get started with Harness CD.

  3. Enter a Stage Name. For this quickstart, enter Teststage.

  4. Select Set Up Stage.

The stage configuration panel opens with the following tabs: Overview, Execution, and Advanced.

Overview tab

The Overview tab contains basic stage information and optional settings.

pipeline overview tab
  1. In the Stage Name field, enter Teststage (if not already entered).
  2. Optionally, add a Description for the stage.
  3. Optionally, add Tags to categorize the stage.
  4. Optionally add a Timeout.
  5. Add a stage variable if needed using Stage variable.
    1. Select + New Variable.

    2. In Type, select the variable type.

    3. In Name, enter a name for the variable.

    4. In Value, enter the variable value.

    5. To require the value when the pipeline runs, select Set variable as required during runtime. You can configure a pipeline setting to accept a value when the pipeline runs instead of specifying a fixed value when you create the pipeline. When you run the pipeline, Harness prompts you to provide a value for the variable. For more information, go to Use runtime input.

    6. Optionally, enter a description in Description.

    7. Select Save to add the variable.

      YAML-Stage variable
      variables:
      - name: name
      type: String
      description: Name description
      required: false
      value: Test

      Reference pipeline variables with <+pipeline.variables.name>.

      Reference stage variables with <+stage.variables.name>.

      For more information, refer to Harness expressions reference.

      If Set variable as required during runtime is selected, the variable value is provided when the pipeline is run rather than being set as a fixed value when you create the variable.

  6. Click Next
Services and Environment tabs

The Service, Environment/Infrastructure tabs are required for Deploy stages and other stage types that require deployment configuration. They are not required for a Custom stage.

For more information, see the Service YAML schema, Environment YAML schema, and Infrastructure Definition YAML schema.

Execution tab

The Execution tab is where you add and configure the steps that run in this stage. For more information, refer to Add a Shell Script step.

pipeline overview tab

Advanced tab

The Advanced tab includes optional configuration that you can add at the stage or step level, depending on your requirements:

  • Conditional Execution: Run the stage only when specific conditions are met. For more information, refer to Conditional execution.
  • Failure Strategy: Define what happens when the stage fails. For more information, refer to Failure strategies.
  • Looping Strategy: Repeat the stage for multiple items or configurations. For more information, refer to Looping strategies.
  • Delegate Selector: Choose which delegate runs this stage. For more information, refer to Delegate overview.
pipeline advanced tab

For example, you can add the pipeline marked as failed for unknown errors as a Failure Strategy.

pipeline advanced tab
YAML - Failure strategy
failureStrategies:
- onFailure:
errors:
- Unknown
action:
type: MarkAsFailure

Add a Shell Script step

Perform the following steps to add a shell script step to the stage.

  1. In the Execution tab, select Add Step.

  2. In the Step Library, search for Shell Script and select it.

  3. Configure the step:

    FieldValue
    NamePrint message
    Timeout10m (default)
    Script TypeBash
    Select script locationInline
    Scriptecho "Hello from Harness!"
    pipeline advanced tab
  4. Select Apply Changes. The step appears on the stage execution canvas.

YAML - Pipeline step
step:
type: ShellScript
name: Print message
identifier: Print_message
spec:
shell: Bash
executionTarget: {}
source:
type: Inline
spec:
script: echo "Hello from Harness!"
environmentVariables: []
outputVariables: []
timeout: 10m

You can arrange steps sequentially, in step groups, or in parallel. Each step type has its own configuration options. For more information about organizing steps into groups, go to Organize steps in step groups.


Run the pipeline

  1. In Pipeline Studio, select Run in the top right corner.

  2. The Run Pipeline dialog opens. This pipeline has no runtime inputs, so no additional configuration is needed.

  3. Select Run Pipeline.

    Harness queues and starts the execution. You are redirected to the execution view.


View execution logs

After the pipeline starts running, the execution view shows the pipeline graph with stage and step status.

  1. On the execution graph, select the Teststage stage.

  2. Select the Print message step.

  3. The Console View panel opens on the right, showing real-time logs for the step.

    You should see output similar to the following:

    Executing command...
    Hello from Harness!
    Command completed with ExitCode (0)
  4. After the step completes, the stage and pipeline statuses update to Success.

pipeline advanced tab

Pipeline YAML

The following example shows the complete YAML for the pipeline created in this quickstart,including the pipeline, stage, step, variables, and failure strategy.

Pipeline YAML
pipeline:
name: DemoPipeline # Your pipeline name.
identifier: DemoPipeline # Your pipeline identifier.
tags: {} # Your pipeline tags.
projectIdentifier: KrishnamoorthyTest # Your project identifier.
orgIdentifier: default # Your organization identifier.
stages: # Your pipeline stages.
- stage:
name: Teststage # Your stage name.
identifier: Teststage # Your stage identifier.
description: "" # Your stage description.
type: Custom # Your stage type.
spec: # Your stage configuration.
execution: # Your stage execution settings.
steps: # Your stage steps.
- step:
type: ShellScript # Your step type.
name: Print message # Your step name.
identifier: Print_message # Your step identifier.
spec: # Your step configuration.
shell: Bash # Your script type.
executionTarget: {} # Your execution target.
source: # Your script source.
type: Inline # Your script location.
spec:
script: echo "Hello from Harness!" # Your script.
environmentVariables: [] # Your environment variables.
outputVariables: [] # Your output variables.
timeout: 10m # Your step timeout.
tags: {} # Your stage tags.
variables: # Your stage variables.
- name: name # Your variable name.
type: String # Your variable type.
description: Name description # Your variable description.
required: false # Your runtime requirement setting.
value: Test # Your variable value.
failureStrategies: # Your failure strategy.
- onFailure:
errors:
- Unknown # Your failure condition.
action:
type: MarkAsFailure # Your failure action.

Next steps