diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2016-01-14 12:57:33 +0000 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2016-01-14 12:57:33 +0000 |
commit | f03da18e3a925e88b46aabb5e095b90abe0f0131 (patch) | |
tree | 9cc013a388489cd6930e654428081a86dc62056a /app/models/ci | |
parent | f981da44ab88012db984e1457170067b345660c1 (diff) | |
parent | be764a3a20c7cecce2a047ddd46aff954c33b306 (diff) | |
download | gitlab-ce-f03da18e3a925e88b46aabb5e095b90abe0f0131.tar.gz |
Merge branch 'ci/view-build-artifacts' into 'master'
Add browser for build artifacts
Discussion in #3426, closes #3426.
See merge request !2123
Diffstat (limited to 'app/models/ci')
-rw-r--r-- | app/models/ci/build.rb | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index a4779d06de8..6cc26abce66 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -30,10 +30,12 @@ # description :string(255) # artifacts_file :text # gl_project_id :integer +# artifacts_metadata :text # module Ci class Build < CommitStatus + include Gitlab::Application.routes.url_helpers LAZY_ATTRIBUTES = ['trace'] belongs_to :runner, class_name: 'Ci::Runner' @@ -49,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 @@ -291,21 +294,18 @@ module Ci end def target_url - Gitlab::Application.routes.url_helpers. - namespace_project_build_url(project.namespace, project, self) + namespace_project_build_url(project.namespace, project, self) end def cancel_url if active? - Gitlab::Application.routes.url_helpers. - cancel_namespace_project_build_path(project.namespace, project, self) + cancel_namespace_project_build_path(project.namespace, project, self) end end def retry_url if retryable? - Gitlab::Application.routes.url_helpers. - retry_namespace_project_build_path(project.namespace, project, self) + retry_namespace_project_build_path(project.namespace, project, self) end end @@ -321,20 +321,35 @@ module Ci pending? && !any_runners_online? end - def download_url - if artifacts_file.exists? - Gitlab::Application.routes.url_helpers. - download_namespace_project_build_path(project.namespace, project, self) - end - end - def execute_hooks build_data = Gitlab::BuildDataBuilder.build(self) project.execute_hooks(build_data.dup, :build_hooks) project.execute_services(build_data.dup, :build_hooks) end + def artifacts? + artifacts_file.exists? + end + + def artifacts_download_url + if artifacts? + download_namespace_project_build_artifacts_path(project.namespace, project, self) + end + end + def artifacts_browse_url + if artifacts_browser_supported? + browse_namespace_project_build_artifacts_path(project.namespace, project, self) + end + end + + def artifacts_browser_supported? + artifacts? && artifacts_metadata.exists? + end + + def artifacts_metadata_entry(path) + Gitlab::Ci::Build::Artifacts::Metadata.new(artifacts_metadata.path, path).to_entry + end private |