diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-01-12 16:39:15 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-01-14 14:48:16 +0300 |
commit | e8995f9fd5c12882eafcf3766627f64a3d6f623d (patch) | |
tree | a7ca8a8f6d599872b846127a891992f7924f5085 /lib/ci/api | |
parent | cf00a808cc9896093be209dc5d6bfbea93b6226b (diff) |
Modify artifacts upload API endpoint, add artifacts metadata
Diffstat (limited to 'lib/ci/api')
-rw-r--r-- | lib/ci/api/builds.rb | 20 | ||||
-rw-r--r-- | lib/ci/api/entities.rb | 1 |
2 files changed, 17 insertions, 4 deletions
diff --git a/lib/ci/api/builds.rb b/lib/ci/api/builds.rb index 15faa6edd84..2aaa06a022c 100644 --- a/lib/ci/api/builds.rb +++ b/lib/ci/api/builds.rb @@ -78,11 +78,15 @@ module Ci # Parameters: # id (required) - The ID of a build # token (required) - The build authorization token - # file (required) - The uploaded file + # file (required) - Artifacts file + # metadata (optional) - Artifacts metadata file # Parameters (accelerated by GitLab Workhorse): # file.path - path to locally stored body (generated by Workhorse) # file.name - real filename as send in Content-Disposition # file.type - real content type as send in Content-Type + # metadata.path - path to locally stored body (generated by Workhorse) + # metadata.name - real filename as send in Content-Disposition + # metadata.type - real content type as send in Content-Type # Headers: # BUILD-TOKEN (required) - The build authorization token, the same as token # Body: @@ -98,10 +102,17 @@ module Ci authenticate_build_token!(build) forbidden!('build is not running') unless build.running? - file = uploaded_file!(:file, ArtifactUploader.artifacts_upload_path) - file_to_large! unless file.size < max_artifacts_size + artifacts_upload_path = ArtifactUploader.artifacts_upload_path + artifacts = uploaded_file!(:file, artifacts_upload_path) + file_to_large! unless artifacts.size < max_artifacts_size + artifacts_attributes = { artifacts_file: artifacts } - if build.update_attributes(artifacts_file: file) + if params[:metadata] || params['metadata.path'.to_sym] + metadata = uploaded_file!(:metadata, artifacts_upload_path) + artifacts_attributes.store(:artifacts_metadata, metadata) + end + + if build.update_attributes(artifacts_attributes) present build, with: Entities::Build else render_validation_error!(build) @@ -148,6 +159,7 @@ module Ci not_found! unless build authenticate_build_token!(build) build.remove_artifacts_file! + build.remove_artifacts_metadata! end end end diff --git a/lib/ci/api/entities.rb b/lib/ci/api/entities.rb index e4ac0545ea2..dd34c661e25 100644 --- a/lib/ci/api/entities.rb +++ b/lib/ci/api/entities.rb @@ -31,6 +31,7 @@ module Ci expose :variables expose :artifacts_file, using: ArtifactFile + expose :artifacts_metadata, using: ArtifactFile end class Runner < Grape::Entity |