summaryrefslogtreecommitdiff
path: root/app/views/projects/ci/builds/_build.html.haml
blob: bdf7b933ab8f497cac1579c371f9540219502547 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
- job = build.present(current_user: current_user)
- pipeline = job.pipeline
- admin = local_assigns.fetch(:admin, false)
- ref = local_assigns.fetch(:ref, nil)
- commit_sha = local_assigns.fetch(:commit_sha, nil)
- retried = local_assigns.fetch(:retried, false)
- pipeline_link = local_assigns.fetch(:pipeline_link, false)
- stage = local_assigns.fetch(:stage, false)
- allow_retry = local_assigns.fetch(:allow_retry, false)

%tr.build.commit{ class: ('retried' if retried) }
  %td.status
    = render "ci/status/badge", status: job.detailed_status(current_user), title: job.status_title

  %td.branch-commit.cgray
    - if can?(current_user, :read_build, job)
      = link_to project_job_path(job.project, job) do
        %span.build-link ##{job.id}
    - else
      %span.build-link ##{job.id}

    - if ref
      - if job.ref
        .icon-container
          = job.tag? ? icon('tag') : sprite_icon('fork', css_class: 'sprite')
        = link_to job.ref, project_ref_path(job.project, job.ref), class: "ref-name"
      - else
        .light= _('none')
      .icon-container.commit-icon
        = custom_icon("icon_commit")

    - if commit_sha
      = link_to job.short_sha, project_commit_path(job.project, job.sha), class: "commit-sha mr-0"

    - if job.stuck?
      = icon('warning', class: 'text-warning has-tooltip', title: _('Job is stuck. Check runners.'))

    - if retried
      = icon('refresh', class: 'text-warning has-tooltip', title: _('Job was retried'))

    .label-container
      - if job.tags.any?
        - job.tags.each do |tag|
          %span.badge.badge-primary
            = tag
      - if job.try(:trigger_request)
        %span.badge.badge-info= _('triggered')
      - if job.try(:allow_failure)
        %span.badge.badge-danger= _('allowed to fail')
      - if job.schedulable?
        %span.badge.badge-info= s_('DelayedJobs|delayed')
      - elsif job.action?
        %span.badge.badge-info= _('manual')

  - if pipeline_link
    %td.pipeline-link
      = link_to pipeline_path(pipeline), class: 'has-tooltip', title: _('Pipeline ID (IID)') do
        %span.pipeline-id ##{pipeline.id}
        %span.pipeline-iid (##{pipeline.iid})
      %span by
      - if pipeline.user
        = user_avatar(user: pipeline.user, size: 20)
      - else
        %span.monospace API

  - if admin
    %td
      - if job.project
        = link_to job.project.full_name, admin_project_path(job.project)
    %td
      - if job.try(:runner)
        = runner_link(job.runner)
      - else
        .light= _('none')

  - if stage
    %td
      = job.stage

  %td
    = job.name

  %td
    - if job.duration
      %p.duration
        = custom_icon("icon_timer")
        = duration_in_numbers(job.duration)

    - if job.finished_at
      %p.finished-at
        = icon("calendar")
        %span= time_ago_with_tooltip(job.finished_at)

  %td.coverage
    - if job.try(:coverage)
      #{job.coverage}%

  %td
    .float-right
      - if can?(current_user, :read_build, job) && job.artifacts?
        = link_to download_project_job_artifacts_path(job.project, job), rel: 'nofollow', download: '', title: _('Download artifacts'), class: 'btn btn-build' do
          = sprite_icon('download')
      - if can?(current_user, :update_build, job)
        - if job.active?
          = link_to cancel_project_job_path(job.project, job, continue: { to: request.fullpath }), method: :post, title: _('Cancel'), class: 'btn btn-build' do
            = icon('remove', class: 'cred')
        - elsif job.scheduled?
          .btn-group
            .btn.btn-default{ disabled: true }
              = sprite_icon('planning')
              %time.js-remaining-time{ datetime: job.scheduled_at.utc.iso8601 }
                = duration_in_numbers(job.execute_in)
            - confirmation_message = s_("DelayedJobs|Are you sure you want to run %{job_name} immediately? This job will run automatically after it's timer finishes.") % { job_name: job.name }
            = link_to play_project_job_path(job.project, job, return_to: request.original_url),
              method: :post,
              title: s_('DelayedJobs|Start now'),
              class: 'btn btn-default btn-build has-tooltip',
              data: { confirm: confirmation_message } do
              = sprite_icon('play')
            = link_to unschedule_project_job_path(job.project, job, return_to: request.original_url),
              method: :post,
              title: s_('DelayedJobs|Unschedule'),
              class: 'btn btn-default btn-build has-tooltip' do
              = sprite_icon('time-out')
        - elsif allow_retry
          - if job.playable? && !admin && can?(current_user, :update_build, job)
            = link_to play_project_job_path(job.project, job, return_to: request.original_url), method: :post, title: _('Play'), class: 'btn btn-build' do
              = custom_icon('icon_play')
          - elsif job.retryable?
            = link_to retry_project_job_path(job.project, job, return_to: request.original_url), method: :post, title: _('Retry'), class: 'btn btn-build' do
              = icon('repeat')