ADD get .trustie-pipeline.yml file api with devops
This commit is contained in:
parent
a22bd280bc
commit
1c2264f721
35
README.md
35
README.md
|
@ -2399,6 +2399,41 @@ https://localhost:3000/api/dev_ops/cloud_accounts.json | jq
|
|||
```
|
||||
---
|
||||
|
||||
#### 获取仓库的.trustie-pipeline.yml
|
||||
```
|
||||
GET /api/dev_ops/builds/get_trustie_pipeline
|
||||
```
|
||||
*示例*
|
||||
```
|
||||
curl -X GET \
|
||||
-d "id=4844" \
|
||||
http://localhost:3000/api/dev_ops/builds/get_trustie_pipeline.json | jq
|
||||
```
|
||||
*请求参数说明:*
|
||||
|
||||
|参数名|必选|类型|说明|
|
||||
|-|-|-|-|
|
||||
|id |是|int |repository's id |
|
||||
|ref |否|string |分支名称、tag名称或是提交记录id,默认为master分支 |
|
||||
|
||||
|
||||
*返回参数说明:*
|
||||
|
||||
|参数名|类型|说明|
|
||||
|-|-|-|
|
||||
|id |int |id |
|
||||
|name |string|文件夹或文件名称|
|
||||
|path |string|文件夹或文件相对路径|
|
||||
|content |string|文件内容,|
|
||||
|
||||
```
|
||||
{
|
||||
"name": ".trustie-pipeline.yml",
|
||||
"path": ".trustie-pipeline.yml",
|
||||
"content": "..jsaf"
|
||||
}
|
||||
```
|
||||
|
||||
#### 获取语言列表
|
||||
```
|
||||
GET /api/dev_ops/languages
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
class ::DevOps::BuildsController < ApplicationController
|
||||
include RepositoriesHelper
|
||||
|
||||
before_action :require_login
|
||||
before_action :find_repo
|
||||
|
||||
|
@ -36,6 +38,19 @@ class ::DevOps::BuildsController < ApplicationController
|
|||
render json: result
|
||||
end
|
||||
|
||||
# get .trustie-pipeline.yml file
|
||||
def get_trustie_pipeline
|
||||
file_path_uri = URI.parse('.trustie-pipeline.yml')
|
||||
interactor = Repositories::EntriesInteractor.call(@repo.user, @repo.identifier, file_path_uri, ref: params[:ref] || "master")
|
||||
if interactor.success?
|
||||
file = interactor.result
|
||||
return render json: {} if file[:status]
|
||||
|
||||
json = {name: file['name'], path: file['path'], content: render_decode64_content(file['content'])}
|
||||
render json: json
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def find_repo
|
||||
@repo = ::Repository.find params[:id]
|
||||
|
|
|
@ -24,6 +24,7 @@ Rails.application.routes.draw do
|
|||
end
|
||||
resources :builds, only: :index do
|
||||
collection do
|
||||
get 'get_trustie_pipeline', to: 'builds#get_trustie_pipeline', as: 'get_trustie_pipeline'
|
||||
get ':number', to: 'builds#detail', as: 'detail'
|
||||
post ':number', to: 'builds#restart', as: 'restart'
|
||||
delete ':number', to: 'builds#delete', as: 'delete'
|
||||
|
|
Loading…
Reference in New Issue