Class: Bard::CI::Jenkins

Inherits:
Struct
  • Object
show all
Defined in:
lib/bard/ci/jenkins.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#branchObject

Returns the value of attribute branch

Returns:

  • (Object)

    the current value of branch



5
6
7
# File 'lib/bard/ci/jenkins.rb', line 5

def branch
  @branch
end

#last_responseObject

Returns the value of attribute last_response.



30
31
32
# File 'lib/bard/ci/jenkins.rb', line 30

def last_response
  @last_response
end

#project_nameObject

Returns the value of attribute project_name

Returns:

  • (Object)

    the current value of project_name



5
6
7
# File 'lib/bard/ci/jenkins.rb', line 5

def project_name
  @project_name
end

#shaObject

Returns the value of attribute sha

Returns:

  • (Object)

    the current value of sha



5
6
7
# File 'lib/bard/ci/jenkins.rb', line 5

def sha
  @sha
end

Instance Method Details

#consoleObject



25
26
27
28
# File 'lib/bard/ci/jenkins.rb', line 25

def console
  raw = `curl -s #{ci_host}/lastBuild/console`
  raw[%r{<pre.*?>(.+)</pre>}m, 1]
end

#exists?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/bard/ci/jenkins.rb', line 21

def exists?
  `curl -s -I #{ci_host}/` =~ /\b200 OK\b/
end

#runObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/bard/ci/jenkins.rb', line 6

def run
  last_time_elapsed = get_last_time_elapsed
  start
  sleep(2) until started?

  start_time = Time.new.to_i
  while building?
    elapsed_time = Time.new.to_i - start_time
    yield elapsed_time, last_time_elapsed
    sleep(2)
  end

  success?
end