Send deployment information in job API

As part of gitlab-org/gitlab-ce#50101 all the deployment information needs to be inside of the json response of projects/jobs_controller#show. This has to extend the BuildDetailsEntity class. Below you can find the template there is in haml, and the json defention that the controller will respond with.

HAML

- if @build.starts_environment?
  .prepend-top-default.js-environment-container
    .environment-information
      - if @build.outdated_deployment?
        = ci_icon_for_status('success_with_warnings')
      - else
        = ci_icon_for_status(@build.status)

      - environment = environment_for_build(@build.project, @build)
      - if @build.success? && @build.last_deployment.present?
        - if @build.last_deployment.last?
          This job is the most recent deployment to #{environment_link_for_build(@build.project, @build)}.
        - else
          This job is an out-of-date deployment to #{environment_link_for_build(@build.project, @build)}.
          View the most recent deployment #{deployment_link(environment.last_deployment)}.
      - elsif @build.complete? && !@build.success?
        The deployment of this job to #{environment_link_for_build(@build.project, @build)} did not succeed.
      - else
        This job is creating a deployment to #{environment_link_for_build(@build.project, @build)}
        - if environment.try(:last_deployment)
          and will overwrite the #{deployment_link(environment.last_deployment, text: 'latest deployment')}

HAML replaced with json keys

- if json.deployment_status
  .prepend-top-default.js-environment-container
    .environment-information
      = ci_icon_for_status(json.deployment_status.icon)

      - if json.deployment_status.status == :latest
        This job is the most recent deployment to #{json.deployment_status.environment.path}.
      - elsif json.deployment_status.status == :out_of_date
        This job is an out-of-date deployment to #{json.deployment_status.environment.path}.
        - if json.deployment_status.environment.last_deployment
          View the most recent deployment #{json.deployment_status.environment.last_deployment.path}.
      - elsif json.deployment_status.status == :failed
        The deployment of this job to #{json.deployment_status.environment.path} did not succeed.
      - elsif json.deployment_status.status == :creating
        This job is creating a deployment to [json.deployment_status.environment.name](#{json.deployment_status.environment.path})
        - if json.deployment_status.environment.last_deployment
          and will overwrite the #{json.deployment_status.environment.last_deployment.path}

JSON

job:
  deployment_status: nil | {
    status: :latest | :out_of_date | :failed | :creating # create virtually,
    icon: '', # created virtually from `ci_status.icon`,
    deployment: { # build.last_deployment
      id: '',
      iid: '',
      path: '',
      latest: true|false,
    },
    environment: {  # build.persisted_environment
      name: '',
      path: '',
      last_deployment: {} # environmnet.last_deployment
    },
  }
Edited by Steve Xuereb