From 703be3f9a15f0905a89f6b4e7a1f8c2cf56d9ffa Mon Sep 17 00:00:00 2001 From: moshenglv Date: Tue, 19 Jan 2021 13:59:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=94=E5=9B=9E=E6=B5=81=E6=B0=B4=E7=BA=BF?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E5=90=8C=E6=AD=A5=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api_document.md | 10 ++++++---- app/controllers/ci/pipelines_controller.rb | 4 +++- app/views/ci/pipelines/content.json.jbuilder | 3 ++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/api_document.md b/api_document.md index 3b35c82a2..f58f6f1ff 100644 --- a/api_document.md +++ b/api_document.md @@ -4191,15 +4191,17 @@ http://localhost:3000/api/ci/pipelines/1/content.json | jq *返回参数说明:* -| 参数名 | 类型 | 说明 | -| ------ | ---- | -------- | -| id | int | 流水线id | +| 参数名 | 类型 | 说明 | +| ------- | ------ | ---------- | +| content | String | 流水线内容 | +| sync | int | 同步状态 | 返回值 ```json { - "content": "#pipeline \nkind: pipeline\r\nname: maven项目-镜像仓库\r\n\r\nplatform:\r\n os: linux\r\n arch: arm64\nsteps:\n- name: Maven编译\r\n image: arm64v8/maven\r\n commands:\r\n - mvn install\n- name: 编译镜像-推送到仓库\r\n image: plugins/docker\r\n settings:\r\n username: moshenglv\r\n password: RL9UB5P7Jtzukka\r\n repo: docker.io/moshenglv/demo\r\n tags: latest\n" + "content": "#pipeline \nkind: pipeline\r\nname: maven项目-镜像仓库\r\n\r\nplatform:\r\n os: linux\r\n arch: arm64\nsteps:\n- name: Maven编译\r\n image: arm64v8/maven\r\n commands:\r\n - mvn install\n- name: 编译镜像-推送到仓库\r\n image: plugins/docker\r\n settings:\r\n username: moshenglv\r\n password: RL9UB5P7Jtzukka\r\n repo: docker.io/moshenglv/demo\r\n tags: latest\n", + "sync": 1 } ``` diff --git a/app/controllers/ci/pipelines_controller.rb b/app/controllers/ci/pipelines_controller.rb index 27641448c..9add4cb45 100644 --- a/app/controllers/ci/pipelines_controller.rb +++ b/app/controllers/ci/pipelines_controller.rb @@ -52,7 +52,9 @@ class Ci::PipelinesController < Ci::BaseController def content @yaml = "#pipeline \n" - stages = Ci::Pipeline.find(params[:id]).pipeline_stages + pipeline = Ci::Pipeline.find(params[:id]) + @sync = pipeline.sync + stages = pipeline.pipeline_stages if stages && !stages.empty? init_step = stages.first.pipeline_stage_steps.first @yaml += init_step.content + "\n" + "steps:\n" diff --git a/app/views/ci/pipelines/content.json.jbuilder b/app/views/ci/pipelines/content.json.jbuilder index f7237bd33..e532dd57c 100644 --- a/app/views/ci/pipelines/content.json.jbuilder +++ b/app/views/ci/pipelines/content.json.jbuilder @@ -1 +1,2 @@ -json.content @yaml \ No newline at end of file +json.content @yaml +json.sync @sync \ No newline at end of file