Class: Ci::ImageForBuildService

Inherits:
Object
  • Object
show all
Defined in:
app/services/ci/image_for_build_service.rb

Instance Method Summary collapse

Instance Method Details

#execute(project, opts) ⇒ Object


3
4
5
6
7
8
9
10
11
12
# File 'app/services/ci/image_for_build_service.rb', line 3

def execute(project, opts)
  sha = opts[:sha] || ref_sha(project, opts[:ref])

  ci_commits = project.ci_commits.where(sha: sha)
  ci_commits = ci_commits.where(ref: opts[:ref]) if opts[:ref]
  image_name = image_for_status(ci_commits.status)

  image_path = Rails.root.join('public/ci', image_name)
  OpenStruct.new(path: image_path, name: image_name)
end