Skip to content

create pipeline: no import path for an existing Git-backed pipeline file #210

Description

@3choBoomer

Summary

There is no way to register an existing Git-backed pipeline file with the CLI. create pipeline --connector/--repo/--file-path maps to the create endpoint, which authors the YAML file in the repo, so it fails whenever the file is already committed — which is the normal Git-experience workflow (commit .harness/pipeline.yaml, then point Harness at it).

Harness has a separate import API for exactly this, and the Harness MCP server exposes it (execute action import, "Fetches the pipeline YAML from the specified repo/branch/path and creates a Harness pipeline record for it"). The CLI has no equivalent — grep -n "import" pkg/spec/pipeline.spec.yaml returns nothing on main.

Related: #211 — together these mean a Git-backed pipeline cannot be set up through the CLI alone.

Version

harness version 3.6.2 (2026-09-01T01:13:47Z)

Also verified against pkg/spec/pipeline.spec.yaml on main (v3.7.1) — unchanged.

Reproduction

With .harness/pipeline.yaml already committed on branch harness-ci-setup:

$ harness create pipeline MyPipeline \
    --connector account.GitHub_Connector \
    --repo my-repo \
    --branch harness-ci-setup \
    --file-path .harness/pipeline.yaml \
    --project MyProject
required flag(s) "file" not set

Adding -f (see note below), the real failure appears:

$ harness create pipeline MyPipeline -f .harness/pipeline.yaml \
    --connector account.GitHub_Connector \
    --repo my-repo \
    --branch harness-ci-setup \
    --file-path .harness/pipeline.yaml \
    --project MyProject
API error 400: Please check if there's already a file [.harness/pipeline.yaml] in
Github repository [my-repo] for the given filepath and branch [harness-ci-setup].
- Check whether the branch [harness-ci-setup] has some protection rules that may
  prohibit creation of new file.

Expected: the pipeline is registered against the existing file.
Actual: 400, because the endpoint tries to create a file that already exists.

Root cause

pkg/spec/pipeline.spec.yaml (L483–511) points create pipeline at the create endpoint:

    endpoint:
      method: POST
      path: /pipeline/api/pipelines/v2
      query_params:
        storeType: 'flags.repo != "" ? "REMOTE" : ""'
        connectorRef: flags.connector
        repoName: flags.repo
        branch: flags.branch
        filePath: flags["file-path"]

That path creates the remote file. The import endpoint is never wired up, and no pipeline:import qualifier exists in the spec.

Suggested fix

Add an import command mapping to the pipeline import API, e.g.:

harness create pipeline:import <id> --connector <ref> --repo <repo> \
  --branch <branch> --file-path <path> [--force]

It takes no -f (the YAML is fetched from Git), and would want --name/--description for the created record, plus a force flag for re-import over an existing pipeline.

Secondary note: -f is required even in Git-backed mode

The help text reads as an either/or:

Create a pipeline: inline from YAML (-f file.yaml) or Git-backed (--connector, --repo, --file-path)

but file_body: required in the spec means -f is mandatory in both modes, and the first command above fails with required flag(s) "file" not set. In Git-backed mode the file content is also redundant with --file-path. Either make -f conditional, or reword the help to say it's always required.

Workaround

Use the Harness MCP server's import action, or the UI's "Import From Git".

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions