create pipeline: no import path for an existing Git-backed pipeline file
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 68/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- git, github, go
- 领域
- api, cli, developer-experience
调研方向
从 pkg/spec/pipeline.spec.yaml 中第 483–511 行附近的 create pipeline 映射开始,并将其与现有的命令限定符和导入 API 模式进行比较。为现有的 Git-backed 文件添加一个导入入口,在不要求 -f 的情况下处理 Git-backed 标志,并验证该命令注册的是现有路径,而不是尝试创建它。
由索引模型根据 Issue 内容生成。
描述
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".
- 主要语言
- Go
- 星标
- 25
- 派生
- 13
- 平均合并
- 2 天 10 小时
- 30 天内合并 PR
- 66
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
harness/cli 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 63/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
beta
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 25/100
维护者通常 1 天内回复
相似的 Issue
-
feat
难度 1/5 1 小时以内 新手友好度 65/100
ory/hydra-maester#312 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 67/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 78/100