forked from Gitlink/forgeplus
返回流水线文件sha
This commit is contained in:
parent
1001d10017
commit
7e9acd1850
|
@ -4179,22 +4179,24 @@ curl --location --request GET 'http://localhost:3000/api/ci/pipelines/19/stages.
|
|||
#### 确认阶段流水线完整内容查询
|
||||
|
||||
```
|
||||
GET /api/ci/pipelines/{id}/content
|
||||
GET /api/ci/pipelines/{id}/content?owner={owner}&repo={repo}
|
||||
```
|
||||
|
||||
*示例*
|
||||
|
||||
```bash
|
||||
curl -X GET \
|
||||
http://localhost:3000/api/ci/pipelines/1/content.json | jq
|
||||
http://localhost:3000/api/ci/pipelines/1/content.json?owner=xx&repo=xx | jq
|
||||
```
|
||||
|
||||
*返回参数说明:*
|
||||
|
||||
| 参数名 | 类型 | 说明 |
|
||||
| ------- | ------ | ---------- |
|
||||
| content | String | 流水线内容 |
|
||||
| sync | int | 同步状态 |
|
||||
| 参数名 | 类型 | 说明 |
|
||||
| ------- | ------ | ---------------- |
|
||||
| content | String | 流水线内容 |
|
||||
| sync | int | 同步状态 |
|
||||
| owner | string | 用户登录名 |
|
||||
| repo | string | 项目的identifier |
|
||||
|
||||
返回值
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ class Ci::PipelinesController < Ci::BaseController
|
|||
|
||||
before_action :require_login, only: %i[list create]
|
||||
skip_before_action :connect_to_ci_db
|
||||
before_action :load_project, only: %i[content]
|
||||
|
||||
# ======流水线相关接口========== #
|
||||
def list
|
||||
|
@ -54,6 +55,7 @@ class Ci::PipelinesController < Ci::BaseController
|
|||
@yaml = "#pipeline \n"
|
||||
pipeline = Ci::Pipeline.find(params[:id])
|
||||
@sync = pipeline.sync
|
||||
@sha = ''
|
||||
stages = pipeline.pipeline_stages
|
||||
if stages && !stages.empty?
|
||||
init_step = stages.first.pipeline_stage_steps.first
|
||||
|
@ -69,8 +71,19 @@ class Ci::PipelinesController < Ci::BaseController
|
|||
end
|
||||
end
|
||||
end
|
||||
if @sync == 1
|
||||
@sha = get_pipeline_file_sha(pipeline.file_name)
|
||||
end
|
||||
end
|
||||
|
||||
def get_pipeline_file_sha(file_name)
|
||||
file_path_uri = URI.parse(file_name)
|
||||
interactor = Repositories::EntriesInteractor.call(@project.owner, @project.identifier, file_path_uri, ref: params[:ref] || "master")
|
||||
if interactor.success?
|
||||
file = interactor.result
|
||||
return file['sha']
|
||||
end
|
||||
end
|
||||
# =========阶段相关接口========= #
|
||||
def stages
|
||||
pipeline_id = params[:id]
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
json.content @yaml
|
||||
json.sync @sync
|
||||
json.sync @sync
|
||||
json.sha @sha
|
Loading…
Reference in New Issue