流水线关联项目
This commit is contained in:
parent
05416339e5
commit
f90bc0897b
|
@ -3283,9 +3283,10 @@ http://localhost:3000/api/jasder/forge/get_trustie_pipeline.json | jq
|
||||||
|
|
||||||
#### 更新'.trustie-pipeline.yml'文件
|
#### 更新'.trustie-pipeline.yml'文件
|
||||||
```
|
```
|
||||||
PUT /api/:owner/:repo/update_trustie_pipeline?pipeline_id={pipeline_id}
|
PUT /api/:owner/:repo/update_trustie_pipeline
|
||||||
```
|
```
|
||||||
*示例*
|
*示例*
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -X GET \
|
curl -X GET \
|
||||||
http://localhost:3000/api/jasder/forge/update_trustie_pipeline.json?pipeline_id=1 | jq
|
http://localhost:3000/api/jasder/forge/update_trustie_pipeline.json?pipeline_id=1 | jq
|
||||||
|
@ -3305,7 +3306,6 @@ http://localhost:3000/api/jasder/forge/update_trustie_pipeline.json?pipeline_id=
|
||||||
|branch |否|string |分支名称, branch和new_branch必须存在一个,且只能存在一个 |
|
|branch |否|string |分支名称, branch和new_branch必须存在一个,且只能存在一个 |
|
||||||
|new_branch |否|string |新的分支名称 |
|
|new_branch |否|string |新的分支名称 |
|
||||||
|ci_language_id |否|string |新的分支名称 |
|
|ci_language_id |否|string |新的分支名称 |
|
||||||
|pipeline_id |是|int |流水线id |
|
|
||||||
|
|
||||||
|
|
||||||
*返回参数说明:*
|
*返回参数说明:*
|
||||||
|
@ -3955,14 +3955,14 @@ https://localhost:3000/api/users/ci/cloud_account/bind.json | jq
|
||||||
#### 流水线查询
|
#### 流水线查询
|
||||||
|
|
||||||
```
|
```
|
||||||
GET /api/ci/pipelines/list?project_id={project_id}
|
GET /api/ci/pipelines/list?identifier={identifier}
|
||||||
```
|
```
|
||||||
|
|
||||||
*示例*
|
*示例*
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -X GET \
|
curl -X GET \
|
||||||
http://localhost:3000/api/ci/pipelines/list.json?project_id=1 | jq
|
http://localhost:3000/api/ci/pipelines/list.json?identifier="xxx" | jq
|
||||||
```
|
```
|
||||||
|
|
||||||
*返回参数说明:*
|
*返回参数说明:*
|
||||||
|
@ -4007,7 +4007,7 @@ curl --location --request POST 'http://localhost:3000/api/ci/pipelines' \
|
||||||
--data-raw ' {
|
--data-raw ' {
|
||||||
"pipeline_name": "流水线 2021-01-12",
|
"pipeline_name": "流水线 2021-01-12",
|
||||||
"file_name": ".trustie.pipeline.yaml",
|
"file_name": ".trustie.pipeline.yaml",
|
||||||
"project_id": 1
|
"identifier": "xxx"
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -4017,7 +4017,7 @@ curl --location --request POST 'http://localhost:3000/api/ci/pipelines' \
|
||||||
| ------------- | ---- | ------ | ---------------------------------------------- |
|
| ------------- | ---- | ------ | ---------------------------------------------- |
|
||||||
| pipeline_name | 是 | string | 流水线名称 |
|
| pipeline_name | 是 | string | 流水线名称 |
|
||||||
| file_name | 是 | string | 文件名称(默认初始值:.trustie.pipeline.yaml) |
|
| file_name | 是 | string | 文件名称(默认初始值:.trustie.pipeline.yaml) |
|
||||||
| project_id | 是 | int | 项目id |
|
| identifier | 是 | string | 项目identifier |
|
||||||
|
|
||||||
*返回参数说明:*
|
*返回参数说明:*
|
||||||
|
|
||||||
|
|
|
@ -5,12 +5,12 @@ class Ci::PipelinesController < Ci::BaseController
|
||||||
|
|
||||||
# ======流水线相关接口========== #
|
# ======流水线相关接口========== #
|
||||||
def list
|
def list
|
||||||
@pipelines = Ci::Pipeline.where('login=? and project_id=?', current_user.login, params[:project_id])
|
@pipelines = Ci::Pipeline.where('login=? and identifier=?', current_user.login, params[:identifier])
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
pipeline = Ci::Pipeline.new(pipeline_name: params[:pipeline_name], file_name: params[:file_name], login: current_user.login, project_id: params[:project_id])
|
pipeline = Ci::Pipeline.new(pipeline_name: params[:pipeline_name], file_name: params[:file_name], login: current_user.login, identifier: params[:identifier])
|
||||||
pipeline.save!
|
pipeline.save!
|
||||||
|
|
||||||
# 默认创建四个初始阶段
|
# 默认创建四个初始阶段
|
||||||
|
|
|
@ -28,20 +28,12 @@ class Ci::ProjectsController < Ci::BaseController
|
||||||
interactor = Gitea::UpdateFileInteractor.call(current_user.gitea_token, params[:owner], params.merge(identifier: @project.identifier))
|
interactor = Gitea::UpdateFileInteractor.call(current_user.gitea_token, params[:owner], params.merge(identifier: @project.identifier))
|
||||||
if interactor.success?
|
if interactor.success?
|
||||||
@file = interactor.result
|
@file = interactor.result
|
||||||
update_pipeline(params[:pipeline_id])
|
|
||||||
render_result(1, "更新成功")
|
render_result(1, "更新成功")
|
||||||
else
|
else
|
||||||
render_error(interactor.error)
|
render_error(interactor.error)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_pipeline(pipeline_id)
|
|
||||||
pipeline = Ci::Pipeline.find(pipeline_id)
|
|
||||||
if pipeline
|
|
||||||
pipeline.update!(sync: 1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def activate
|
def activate
|
||||||
return render_error('你还未认证') unless current_user.ci_certification?
|
return render_error('你还未认证') unless current_user.ci_certification?
|
||||||
|
|
||||||
|
|
|
@ -94,11 +94,22 @@ class RepositoriesController < ApplicationController
|
||||||
if interactor.success?
|
if interactor.success?
|
||||||
@file = interactor.result
|
@file = interactor.result
|
||||||
# create_new_pr(params)
|
# create_new_pr(params)
|
||||||
|
#如果是更新流水线文件
|
||||||
|
if params[:pipeline_id]
|
||||||
|
update_pipeline(params[:pipeline_id])
|
||||||
|
end
|
||||||
else
|
else
|
||||||
render_error(interactor.error)
|
render_error(interactor.error)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update_pipeline(pipeline_id)
|
||||||
|
pipeline = Ci::Pipeline.find(pipeline_id)
|
||||||
|
if pipeline
|
||||||
|
pipeline.update!(sync: 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def update_file
|
def update_file
|
||||||
interactor = Gitea::UpdateFileInteractor.call(current_user.gitea_token, @owner.login, params.merge(identifier: @project.identifier))
|
interactor = Gitea::UpdateFileInteractor.call(current_user.gitea_token, @owner.login, params.merge(identifier: @project.identifier))
|
||||||
if interactor.success?
|
if interactor.success?
|
||||||
|
|
|
@ -3,6 +3,6 @@ json.pipeline_name pipeline.pipeline_name
|
||||||
json.pipeline_status pipeline.pipeline_status
|
json.pipeline_status pipeline.pipeline_status
|
||||||
json.file_name pipeline.file_name
|
json.file_name pipeline.file_name
|
||||||
json.sync pipeline.sync
|
json.sync pipeline.sync
|
||||||
json.project_id pipeline.project_id
|
json.identifier pipeline.identifier
|
||||||
json.created_at pipeline.created_at.strftime("%Y-%m-%d %H:%M:%S")
|
json.created_at pipeline.created_at.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
json.updated_at pipeline.updated_at.strftime("%Y-%m-%d %H:%M:%S")
|
json.updated_at pipeline.updated_at.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
class AddSyncAndProjectIdToCiPipelines < ActiveRecord::Migration[5.2]
|
class AddSyncAndProjectIdToCiPipelines < ActiveRecord::Migration[5.2]
|
||||||
def change
|
def change
|
||||||
add_column :ci_pipelines, :sync, :integer, null: false, comment: '0 未同步到gitea,1 已同步', default: 0
|
add_column :ci_pipelines, :sync, :integer, null: false, comment: '0 未同步到gitea,1 已同步', default: 0
|
||||||
add_column :ci_pipelines, :project_id, :integer
|
add_column :ci_pipelines, :identifier, :string
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue