debian-mirror-gitlab/lib/gitlab/data_builder/deployment.rb

45 lines
1.2 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
module Gitlab
module DataBuilder
module Deployment
extend self
2021-06-08 01:23:25 +05:30
def build(deployment, status_changed_at)
2019-12-26 22:10:19 +05:30
# Deployments will not have a deployable when created using the API.
deployable_url =
if deployment.deployable
Gitlab::UrlBuilder.build(deployment.deployable)
end
2022-06-21 17:19:12 +05:30
commit_url =
if (commit = deployment.commit)
Gitlab::UrlBuilder.build(commit)
end
user_url =
if deployment.deployed_by
Gitlab::UrlBuilder.build(deployment.deployed_by)
end
2019-07-31 22:56:46 +05:30
{
object_kind: 'deployment',
status: deployment.status,
2021-06-08 01:23:25 +05:30
status_changed_at: status_changed_at,
2021-10-27 15:23:28 +05:30
deployment_id: deployment.id,
2019-07-31 22:56:46 +05:30
deployable_id: deployment.deployable_id,
2019-12-26 22:10:19 +05:30
deployable_url: deployable_url,
2019-07-31 22:56:46 +05:30
environment: deployment.environment.name,
project: deployment.project.hook_attrs,
short_sha: deployment.short_sha,
2022-06-21 17:19:12 +05:30
user: deployment.deployed_by&.hook_attrs,
user_url: user_url,
commit_url: commit_url,
commit_title: deployment.commit_title,
2022-03-02 08:16:31 +05:30
ref: deployment.ref
2019-07-31 22:56:46 +05:30
}
end
end
end
end