summaryrefslogtreecommitdiff
path: root/lib/gitlab/data_builder/build.rb
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2016-08-30 13:49:31 +0100
committerPhil Hughes <me@iamphill.com>2016-08-30 13:49:31 +0100
commit172aab108b875e8dc9a5f1d3c2d53018eff76ea1 (patch)
tree068fa858eeaa8faa7c65f189d8189e33a83c86a3 /lib/gitlab/data_builder/build.rb
parent45fa7fd4ddf35314602168cd869ee4a67c44250b (diff)
parent2778dec131c2afac9fcdb2c42365b69099a5ae5b (diff)
downloadgitlab-ce-172aab108b875e8dc9a5f1d3c2d53018eff76ea1.tar.gz
Merge branch 'master' into autocomplete-space-prefix
Diffstat (limited to 'lib/gitlab/data_builder/build.rb')
-rw-r--r--lib/gitlab/data_builder/build.rb67
1 files changed, 67 insertions, 0 deletions
diff --git a/lib/gitlab/data_builder/build.rb b/lib/gitlab/data_builder/build.rb
new file mode 100644
index 00000000000..6548e6475c6
--- /dev/null
+++ b/lib/gitlab/data_builder/build.rb
@@ -0,0 +1,67 @@
+module Gitlab
+ module DataBuilder
+ module Build
+ extend self
+
+ def build(build)
+ project = build.project
+ commit = build.pipeline
+ user = build.user
+
+ data = {
+ object_kind: 'build',
+
+ ref: build.ref,
+ tag: build.tag,
+ before_sha: build.before_sha,
+ sha: build.sha,
+
+ # TODO: should this be not prefixed with build_?
+ # Leaving this way to have backward compatibility
+ build_id: build.id,
+ build_name: build.name,
+ build_stage: build.stage,
+ build_status: build.status,
+ build_started_at: build.started_at,
+ build_finished_at: build.finished_at,
+ build_duration: build.duration,
+ build_allow_failure: build.allow_failure,
+
+ # TODO: do we still need it?
+ project_id: project.id,
+ project_name: project.name_with_namespace,
+
+ user: {
+ id: user.try(:id),
+ name: user.try(:name),
+ email: user.try(:email),
+ },
+
+ commit: {
+ id: commit.id,
+ sha: commit.sha,
+ message: commit.git_commit_message,
+ author_name: commit.git_author_name,
+ author_email: commit.git_author_email,
+ status: commit.status,
+ duration: commit.duration,
+ started_at: commit.started_at,
+ finished_at: commit.finished_at,
+ },
+
+ repository: {
+ name: project.name,
+ url: project.url_to_repo,
+ description: project.description,
+ homepage: project.web_url,
+ git_http_url: project.http_url_to_repo,
+ git_ssh_url: project.ssh_url_to_repo,
+ visibility_level: project.visibility_level
+ },
+ }
+
+ data
+ end
+ end
+ end
+end