Class: Jenkins::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/jenkins-client/job.rb,
lib/jenkins-client/client.rb,
lib/jenkins-client/version.rb

Defined Under Namespace

Classes: Job

Constant Summary collapse

VERSION =
"0.0.1"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.connectionObject

Returns the value of attribute connection.



8
9
10
# File 'lib/jenkins-client/client.rb', line 8

def connection
  @connection
end

.passwordObject

Returns the value of attribute password.



8
9
10
# File 'lib/jenkins-client/client.rb', line 8

def password
  @password
end

.urlObject

Returns the value of attribute url.



8
9
10
# File 'lib/jenkins-client/client.rb', line 8

def url
  @url
end

.usernameObject

Returns the value of attribute username.



8
9
10
# File 'lib/jenkins-client/client.rb', line 8

def username
  @username
end

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



10
11
12
13
# File 'lib/jenkins-client/client.rb', line 10

def configure
  yield self
  setup_connection
end

.get(path) ⇒ Object



24
25
26
# File 'lib/jenkins-client/client.rb', line 24

def get(path)
  connection.get(path)
end

.post(path, body) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/jenkins-client/client.rb', line 28

def post(path, body)
  resp = @connection.post do |req|
    req.headers['Content-Type'] = 'application/xml'
    req.url path
    req.body = body
  end
  resp.status == 200
end

.setup_connectionObject



15
16
17
18
19
20
21
22
# File 'lib/jenkins-client/client.rb', line 15

def setup_connection
  @connection = Faraday.new(:url => url) do |builder|
    builder.use FaradayMiddleware::Rashify
    builder.use FaradayMiddleware::ParseJson
    builder.adapter  :net_http
  end
  @connection.basic_auth username, password
end