2019-04-26 17:08:41 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module DataBuilder
|
|
|
|
module Deployment
|
|
|
|
extend self
|
|
|
|
|
2021-04-29 14:10:23 -04:00
|
|
|
def build(deployment, status_changed_at)
|
2019-11-06 19:06:18 -05:00
|
|
|
# Deployments will not have a deployable when created using the API.
|
|
|
|
deployable_url =
|
|
|
|
if deployment.deployable
|
|
|
|
Gitlab::UrlBuilder.build(deployment.deployable)
|
|
|
|
end
|
|
|
|
|
2019-04-26 17:08:41 -04:00
|
|
|
{
|
|
|
|
object_kind: 'deployment',
|
|
|
|
status: deployment.status,
|
2021-04-29 14:10:23 -04:00
|
|
|
status_changed_at: status_changed_at,
|
2019-04-26 17:08:41 -04:00
|
|
|
deployable_id: deployment.deployable_id,
|
2019-11-06 19:06:18 -05:00
|
|
|
deployable_url: deployable_url,
|
2019-04-26 17:08:41 -04:00
|
|
|
environment: deployment.environment.name,
|
|
|
|
project: deployment.project.hook_attrs,
|
|
|
|
short_sha: deployment.short_sha,
|
2020-10-05 02:08:45 -04:00
|
|
|
user: deployment.deployed_by.hook_attrs,
|
|
|
|
user_url: Gitlab::UrlBuilder.build(deployment.deployed_by),
|
2019-05-02 12:07:26 -04:00
|
|
|
commit_url: Gitlab::UrlBuilder.build(deployment.commit),
|
|
|
|
commit_title: deployment.commit.title
|
2019-04-26 17:08:41 -04:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|