From 662f4b9e1dec8e461c4ea8da3ccc46a259d9d205 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 30 Dec 2015 14:41:44 +0100 Subject: Add artifacts metadata uploader filed Artifacts metadata field will be used to store a filename of gzipped file containing metadata definition for given artifacts archive. --- app/controllers/projects/artifacts_controller.rb | 2 +- app/models/ci/build.rb | 8 +++++--- .../20151230132518_add_artifacts_metadata_to_ci_build.rb | 5 +++++ db/schema.rb | 1 + spec/fixtures/ci_build_artifacts_metadata.gz | Bin 0 -> 279 bytes 5 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20151230132518_add_artifacts_metadata_to_ci_build.rb create mode 100644 spec/fixtures/ci_build_artifacts_metadata.gz diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index 18677fb1e95..8a1ff383134 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -18,7 +18,7 @@ class Projects::ArtifactsController < Projects::ApplicationController return render_404 unless build.artifacts? current_path = params[:path] ? "./#{params[:path]}/" : './' - artifacts_metadata = build.artifacts_metadata(current_path) + artifacts_metadata = build.artifacts_metadata_for(current_path) @path = Gitlab::StringPath.new(current_path, artifacts_metadata) end diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index ee82fe824c5..98f9e6911f2 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -30,6 +30,7 @@ # description :string(255) # artifacts_file :text # gl_project_id :integer +# artifacts_metadata :text # module Ci @@ -50,6 +51,7 @@ module Ci scope :similar, ->(build) { where(ref: build.ref, tag: build.tag, trigger_request_id: build.trigger_request_id) } mount_uploader :artifacts_file, ArtifactUploader + mount_uploader :artifacts_metadata, ArtifactUploader acts_as_taggable @@ -344,11 +346,11 @@ module Ci def artifacts_browser_supported? # TODO, since carrierwave 0.10.0 we will be able to check mime type here # - artifacts? && artifacts_file.path.end_with?('zip') + artifacts? && artifacts_file.path.end_with?('zip') && artifacts_metadata.exists? end - def artifacts_metadata(path) - [] + def artifacts_metadata_for(path) + {} end private diff --git a/db/migrate/20151230132518_add_artifacts_metadata_to_ci_build.rb b/db/migrate/20151230132518_add_artifacts_metadata_to_ci_build.rb new file mode 100644 index 00000000000..6c282fc5039 --- /dev/null +++ b/db/migrate/20151230132518_add_artifacts_metadata_to_ci_build.rb @@ -0,0 +1,5 @@ +class AddArtifactsMetadataToCiBuild < ActiveRecord::Migration + def change + add_column :ci_builds, :artifacts_metadata, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 42c3e79f9d7..2fc8c4d5ed4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -123,6 +123,7 @@ ActiveRecord::Schema.define(version: 20160113111034) do t.string "description" t.text "artifacts_file" t.integer "gl_project_id" + t.text "artifacts_metadata" end add_index "ci_builds", ["commit_id", "stage_idx", "created_at"], name: "index_ci_builds_on_commit_id_and_stage_idx_and_created_at", using: :btree diff --git a/spec/fixtures/ci_build_artifacts_metadata.gz b/spec/fixtures/ci_build_artifacts_metadata.gz new file mode 100644 index 00000000000..bd0c8ada20a Binary files /dev/null and b/spec/fixtures/ci_build_artifacts_metadata.gz differ -- cgit v1.2.1