Class: Concourse::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/concourse/job.rb

Overview

A job belongs to a pipeline A job has many builds A job has one finished_build A job has one next_build

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pipeline, info) ⇒ Job

Returns a new instance of Job.



15
16
17
18
# File 'lib/concourse/job.rb', line 15

def initialize(pipeline, info)
  @pipeline = pipeline
  @info = info
end

Instance Attribute Details

#pipelineObject (readonly)

Returns the value of attribute pipeline.



13
14
15
# File 'lib/concourse/job.rb', line 13

def pipeline
  @pipeline
end

Instance Method Details

#buildsObject



28
29
30
31
32
# File 'lib/concourse/job.rb', line 28

def builds
  JSON.parse(@pipeline.get("/#{CGI.escape(name)}/builds")).map do |build|
    Build.new(self, build)
  end
end

#finished_buildObject



34
35
36
# File 'lib/concourse/job.rb', line 34

def finished_build
  Build.new(self, @info['finished_build']) if @info['finished_build']
end

#nameObject



20
21
22
# File 'lib/concourse/job.rb', line 20

def name
  @info['name']
end

#next_buildObject



38
39
40
41
# File 'lib/concourse/job.rb', line 38

def next_build
  next_build = @info['next_build']
  Build.new(self, next_build) if next_build
end

#to_sObject



24
25
26
# File 'lib/concourse/job.rb', line 24

def to_s
  "#{self.class.name.split('::').last.downcase} #{name} of #{pipeline}"
end