Class: Lhj::JenkinsApi::Client

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

Overview

This is the client class that acts as the bridge between the subclasses and Jenkins. This class contains methods that performs GET and POST requests for various operations.

Defined Under Namespace

Classes: Job

Constant Summary collapse

DEFAULT_SERVER_PORT =

Default port to be used to connect to Jenkins

8080
DEFAULT_TIMEOUT =

Default timeout in seconds to be used while performing operations

120
DEFAULT_HTTP_OPEN_TIMEOUT =
10
DEFAULT_HTTP_READ_TIMEOUT =
120
VALID_PARAMS =

Parameters that are permitted as options while initializing the client

[
  "server_url",
  "server_ip",
  "server_port",
  "proxy_ip",
  "proxy_port",
  "proxy_protocol",
  "jenkins_path",
  "username",
  "password",
  "password_base64",
  "logger",
  "log_location",
  "log_level",
  "timeout",
  "http_open_timeout",
  "http_read_timeout",
  "ssl",
  "pkcs_file_path",
  "pass_phrase",
  "ca_file",
  "follow_redirects",
  "identity_file",
  "cookies"
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ JenkinsApi::Client

Initialize a Client object with Jenkins CI server credentials

Parameters:

  • args (Hash)

    Arguments to connect to Jenkins server

Options Hash (args):

  • :server_ip (String)

    the IP address of the Jenkins CI server

  • :server_port (String)

    the port on which the Jenkins listens

  • :server_url (String)

    the full URL address of the Jenkins CI server (http/https). This can include username/password. :username/:password options will override any user/pass value in the URL

  • :username (String)

    the username used for connecting to the server (optional)

  • :password (String)

    the password or API Key for connecting to the CI server (optional)

  • :password_base64 (String)

    the password with base64 encoded format for connecting to the CI server (optional)

  • :identity_file (String)

    the priviate key file for Jenkins CLI authentication, it is used only for executing CLI commands. Also remember to upload the public key to <Server IP>:<Server Port>/user/<Username>/configure

  • :proxy_ip (String)

    the proxy IP address

  • :proxy_port (String)

    the proxy port

  • :proxy_protocol (String)

    the proxy protocol (‘socks’ or ‘http’ (defaults to HTTP)

  • :jenkins_path (String) — default: "/"

    the optional context path for Jenkins

  • :ssl (Boolean) — default: false

    indicates if Jenkins is accessible over HTTPS

  • :pkcs_file_path (String) — default: "/"

    the optional context path for pfx or p12 binary certificate file

  • :pass_phrase (String)

    password for pkcs_file_path certificate file

  • :ca_file (String)

    the path to a PEM encoded file containing trusted certificates used to verify peer certificate

  • :follow_redirects (Boolean)

    this argument causes the client to follow a redirect (jenkins can return a 30x when starting a build)

  • :timeout (Fixnum) — default: 120

    This argument sets the timeout for operations that take longer (in seconds)

  • :logger (Logger)

    a Logger object, used to override the default logger (optional)

  • :log_location (String) — default: STDOUT

    the location for the log file

  • :log_level (Fixnum) — default: Logger::INFO

    The level for messages to be logged. Should be one of: Logger::DEBUG (0), Logger::INFO (1), Logger::WARN (2), Logger::ERROR (2), Logger::FATAL (3)

  • :cookies (String)

    Cookies to be sent with all requests in the format: name=value; name2=value2

Raises:

  • (ArgumentError)

    when required options are not provided.



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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/lhj/jenkins/client.rb', line 87

def initialize(args)
  args = symbolize_keys(args)
  args.each do |key, value|
    if value && VALID_PARAMS.include?(key.to_s)
      instance_variable_set("@#{key}", value)
    end
  end if args.is_a? Hash

  # Server IP or Server URL must be specific
  unless @server_ip || @server_url
    raise ArgumentError, "Server IP or Server URL is required to connect" +
      " to Jenkins"
  end

  # Get info from the server_url, if we got one
  if @server_url
    server_uri = URI.parse(@server_url)
    @server_ip = server_uri.host
    @server_port = server_uri.port
    @ssl = server_uri.scheme == "https"
    @jenkins_path = server_uri.path

    # read username and password from the URL
    # only set if @username and @password are not already set via explicit options
    @username ||= server_uri.user
    @password ||= server_uri.password
  end

  # Username/password are optional as some jenkins servers do not require
  # authentication
  if @username && !(@password || @password_base64)
    raise ArgumentError, "If username is provided, password is required"
  end
  if @proxy_ip.nil? ^ @proxy_port.nil?
    raise ArgumentError, "Proxy IP and port must both be specified or" +
      " both left nil"
  end

  @jenkins_path ||= ""
  @jenkins_path.gsub!(/\/$/, "") # remove trailing slash if there is one
  @server_port = DEFAULT_SERVER_PORT unless @server_port
  @timeout = DEFAULT_TIMEOUT unless @timeout
  @http_open_timeout = DEFAULT_HTTP_OPEN_TIMEOUT unless @http_open_timeout
  @http_read_timeout = DEFAULT_HTTP_READ_TIMEOUT unless @http_read_timeout
  @ssl ||= false
  @proxy_protocol ||= 'http'

  # Setting log options
  if @logger
    raise ArgumentError, "logger parameter must be a Logger object" unless @logger.is_a?(Logger)
    raise ArgumentError, "log_level should not be set if using custom logger" if @log_level
    raise ArgumentError, "log_location should not be set if using custom logger" if @log_location
  else
    @log_location = STDOUT unless @log_location
    @log_level = Logger::INFO unless @log_level
    @logger = Logger.new(@log_location)
    @logger.level = @log_level
  end

  # Base64 decode inserts a newline character at the end. As a workaround
  # added chomp to remove newline characters. I hope nobody uses newline
  # characters at the end of their passwords :)
  @password = Base64.decode64(@password_base64).chomp if @password_base64

  # No connections are made to the Jenkins server during initialize to
  # allow the unit tests to behave normally as mocking is simpler this way.
  # If this variable is nil, the first POST request will query the API and
  # populate this variable.
  @crumbs_enabled = nil
  # The crumbs hash. Store it so that we don't have to obtain the crumb for
  # every POST request. It appears that the crumb doesn't change often.
  @crumb = {}
  # This is the number of times to refetch the crumb if it ever expires.
  @crumb_max_retries = 3
  @header = {}
end

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



17
18
19
# File 'lib/lhj/jenkins/client.rb', line 17

def logger
  @logger
end

#timeoutObject

Returns the value of attribute timeout.



17
18
19
# File 'lib/lhj/jenkins/client.rb', line 17

def timeout
  @timeout
end

Instance Method Details

#api_get_request(url_prefix, tree = nil, url_suffix = "/api/json", raw_response = false) ⇒ String, Hash

Sends a GET request to the Jenkins CI server with the specified URL

Parameters:

  • url_prefix (String)

    The prefix to use in the URL

  • tree (String) (defaults to: nil)

    A specific JSON tree to optimize the API call

  • url_suffix (String) (defaults to: "/api/json")

    The suffix to be used in the URL

  • raw_response (Boolean) (defaults to: false)

    Return complete Response object instead of JSON body of response

Returns:

  • (String, Hash)

    JSON response from Jenkins



389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
# File 'lib/lhj/jenkins/client.rb', line 389

def api_get_request(url_prefix, tree = nil, url_suffix = "/api/json",
                    raw_response = false)
  url_prefix = "#{@jenkins_path}#{url_prefix}"
  to_get = ""
  if tree
    to_get = "#{url_prefix}#{url_suffix}?#{tree}"
  else
    to_get = "#{url_prefix}#{url_suffix}"
  end
  request = Net::HTTP::Get.new(to_get)
  @logger.debug "GET #{to_get}"
  response = make_http_request(request)
  if raw_response
    handle_exception(response, "raw")
  else
    handle_exception(response, "body", url_suffix =~ /json/)
  end
end

#api_post_request(url_prefix, form_data = {}, raw_response = false) ⇒ String

Sends a POST message to the Jenkins CI server with the specified URL

Parameters:

  • url_prefix (String)

    The prefix to be used in the URL

  • form_data (Hash) (defaults to: {})

    Form data to send with POST request

  • raw_response (Boolean) (defaults to: false)

    Return complete Response object instead of JSON body of response

Returns:

  • (String)

    Response code form Jenkins Response



417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
# File 'lib/lhj/jenkins/client.rb', line 417

def api_post_request(url_prefix, form_data = {}, raw_response = false)
  retries = @crumb_max_retries
  begin
    refresh_crumbs

    # Added form_data default {} instead of nil to help with proxies
    # that barf with empty post
    request = Net::HTTP::Post.new("#{@jenkins_path}#{url_prefix}")
    @logger.debug "POST #{url_prefix}"
    if @crumbs_enabled
      request[@crumb["crumbRequestField"]] = @crumb["crumb"]
      request['Cookie'] = @header['set-cookie'] if @header
    end
    request.set_form_data(form_data)
    response = make_http_request(request)
    if raw_response
      handle_exception(response, "raw")
    else
      handle_exception(response)
    end
  rescue Exceptions::ForbiddenException => e
    refresh_crumbs(true)

    if @crumbs_enabled
      @logger.info "Retrying: #{@crumb_max_retries - retries + 1} out of" +
                     " #{@crumb_max_retries} times..."
      retries -= 1

      if retries > 0
        retry
      else
        raise Exceptions::ForbiddenWithCrumb.new(@logger, e.message)
      end
    else
      raise
    end
  end
end

#compare_versions(version_a, version_b) ⇒ Object

Compare two version strings (A and B) if A == B, returns 0 if A > B, returns 1 if A < B, returns -1



598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
# File 'lib/lhj/jenkins/client.rb', line 598

def compare_versions(version_a, version_b)
  if version_a == version_b
    return 0
  else
    version_a_d = deconstruct_version_string(version_a)
    version_b_d = deconstruct_version_string(version_b)

    if version_a_d[0] > version_b_d[0] ||
      (version_a_d[0] == version_b_d[0] && version_a_d[1] > version_b_d[1]) ||
      (version_a_d[0] == version_b_d[0] && version_a_d[1] == version_b_d[1] && version_a_d[2] > version_b_d[2])
      return 1
    else
      return -1
    end
  end
end

#deconstruct_version_string(version) ⇒ Object

Converts a version string to a list of integers This makes it easier to compare versions since in ‘version-speak’, v 1.2 is a lot older than v 1.102 - and simple < > on version strings doesn’t work so well



582
583
584
585
586
587
588
589
590
591
592
# File 'lib/lhj/jenkins/client.rb', line 582

def deconstruct_version_string(version)
  match = version.match(/^(\d+)\.(\d+)(?:\.(\d+))?$/)

  # Match should have 4 parts [0] = input string, [1] = major
  # [2] = minor, [3] = patch (possibly blank)
  if match && match.size == 4
    return [match[1].to_i, match[2].to_i, match[3].to_i || 0]
  else
    return nil
  end
end

#exec_cli(command, args = []) ⇒ String

Execute the Jenkins CLI

Parameters:

  • command (String)

    command name

  • args (Array) (defaults to: [])

    the arguments for the command

Returns:

  • (String)

    command output from the CLI

Raises:



645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
# File 'lib/lhj/jenkins/client.rb', line 645

def exec_cli(command, args = [])
  base_dir = File.dirname(__FILE__)
  server_url = "http://#{@server_ip}:#{@server_port}/#{@jenkins_path}"
  cmd = "java -jar #{base_dir}/../../java_deps/jenkins-cli.jar -s #{server_url}"
  cmd << " -i #{@identity_file}" if @identity_file && !@identity_file.empty?
  cmd << " #{command}"
  cmd << " --username #{@username} --password #{@password}" if @identity_file.nil? || @identity_file.empty?
  cmd << ' '
  cmd << args.join(' ')
  java_cmd = Mixlib::ShellOut.new(cmd)

  # Run the command
  java_cmd.run_command
  if java_cmd.stderr.empty?
    java_cmd.stdout.chomp
  else
    # The stderr has a stack trace of the Java program. We'll already have
    # a stack trace for Ruby. So just display a descriptive message for the
    # error thrown by the CLI.
    raise Exceptions::CLIException.new(
      @logger,
      java_cmd.stderr.split("\n").first
    )
  end
end

#exec_script(script_text) ⇒ String

Executes the provided groovy script on the Jenkins CI server

Parameters:

  • script_text (String)

    The text of the groovy script to execute

Returns:

  • (String)

    The output of the executed groovy script



630
631
632
633
# File 'lib/lhj/jenkins/client.rb', line 630

def exec_script(script_text)
  response = api_post_request('/scriptText', { 'script' => script_text }, true)
  response.body
end

#get_artifact(job_name, filename) ⇒ Object

Connects to the server and downloads artifacts to a specified location

Parameters:

  • job_name (String)
  • filename (String)

    location to save artifact



260
261
262
263
264
265
266
267
268
# File 'lib/lhj/jenkins/client.rb', line 260

def get_artifact(job_name, filename)
  @artifact = job.find_artifact(job_name)
  response = make_http_request(Net::HTTP::Get.new(@artifact))
  if response.code == "200"
    File.write(File.expand_path(filename), response.body)
  else
    raise "Couldn't get the artifact"
  end
end

#get_artifacts(job_name, dldir, build_number = nil) ⇒ Object

Connects to the server and download all artifacts of a build to a specified location

Parameters:

  • job_name (String)
  • dldir (String)

    location to save artifacts

  • build_number (Integer) (defaults to: nil)

    optional, defaults to current build



277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
# File 'lib/lhj/jenkins/client.rb', line 277

def get_artifacts(job_name, dldir, build_number = nil)
  @artifacts = job.find_artifacts(job_name, build_number)
  results = []
  @artifacts.each do |artifact|
    uri = URI.parse(artifact)
    http = Net::HTTP.new(uri.host, uri.port)
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
    http.use_ssl = @ssl
    request = Net::HTTP::Get.new(uri.request_uri)
    request.basic_auth(@username, @password)
    response = http.request(request)
    # we want every thing after the last 'build' in the path to become the filename
    if artifact.include?('/build/')
      filename = artifact.split("/build/").last.gsub('/', '-')
    else
      filename = File.basename(artifact)
    end
    filename = File.join(dldir, filename)
    results << filename
    if response.code == "200"
      File.write(File.expand_path(filename), response.body)
    else
      raise "Couldn't get the artifact #{artifact} for job #{job}"
    end
  end
  results
end

#get_config(url_prefix) ⇒ String

Obtains the configuration of a component from the Jenkins CI server

Parameters:

  • url_prefix (String)

    The prefix to be used in the URL

Returns:

  • (String)

    XML configuration obtained from Jenkins



462
463
464
465
466
467
# File 'lib/lhj/jenkins/client.rb', line 462

def get_config(url_prefix)
  request = Net::HTTP::Get.new("#{@jenkins_path}#{url_prefix}/config.xml")
  @logger.debug "GET #{url_prefix}/config.xml"
  response = make_http_request(request)
  handle_exception(response, "body")
end

#get_hudson_versionString

Obtain the Hudson version of the CI server Only queries Hudson/Jenkins if the version is not already stored. Note that the version is auto-updated after every request made to Jenkins since it is returned as a header in every response

Returns:

  • (String)

    Version of Hudson on Jenkins server



573
574
575
576
# File 'lib/lhj/jenkins/client.rb', line 573

def get_hudson_version
  get_root if @hudson_version.nil?
  @hudson_version
end

#get_jenkins_versionString

Obtains the jenkins version from the API Only queries Jenkins if the version is not already stored. Note that the version is auto-updated after every request made to Jenkins since it is returned as a header in every response

Returns:

  • (String)

    Jenkins version



561
562
563
564
# File 'lib/lhj/jenkins/client.rb', line 561

def get_jenkins_version
  get_root if @jenkins_version.nil?
  @jenkins_version
end

#get_rootNet::HTTP::Response

Obtains the root of Jenkins server. This function is used to see if Jenkins is running

Returns:

  • (Net::HTTP::Response)

    Response from Jenkins for “/”



373
374
375
376
377
# File 'lib/lhj/jenkins/client.rb', line 373

def get_root
  @logger.debug "GET #{@jenkins_path}/"
  request = Net::HTTP::Get.new("#{@jenkins_path}/")
  make_http_request(request)
end

#get_server_dateString

Obtain the date of the Jenkins server

Returns:



619
620
621
622
# File 'lib/lhj/jenkins/client.rb', line 619

def get_server_date
  response = get_root
  response["Date"]
end

#init_update_centerObject



517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
# File 'lib/lhj/jenkins/client.rb', line 517

def init_update_center
  @logger.info "Initializing Jenkins Update Center..."
  @logger.debug "Obtaining the JSON data for Update Center..."
  # TODO: Clean me up
  update_center_data = open("https://updates.jenkins.io/current/update-center.json").read
  # The Jenkins mirror returns the data in the following format
  #   updateCenter.post(
  #     {.. JSON data...}
  #   );
  # which is used by the Javascript used by the Jenkins UI to send to Jenkins.
  #
  update_center_data.gsub!("updateCenter.post(\n", "")
  update_center_data.gsub!("\n);", "")

  @logger.debug "Posting the obtained JSON to Jenkins Update Center..."
  post_json("/updateCenter/byId/default/postBack", update_center_data)
end

#inspectObject

Overrides the inspect method to get rid of the credentials being shown in the in interactive IRB sessions and also when the ‘inspect` method is called. Just print the important variables.



241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/lhj/jenkins/client.rb', line 241

def inspect
  "#<JenkinsApi::Client:0x#{(self.__id__ * 2).to_s(16)}" +
    " @ssl=#{@ssl.inspect}," +
    " @ca_file=#{@ca_file.inspect}," +
    " @log_location=#{@log_location.inspect}," +
    " @log_level=#{@log_level.inspect}," +
    " @crumbs_enabled=#{@crumbs_enabled.inspect}," +
    " @follow_redirects=#{@follow_redirects.inspect}," +
    " @jenkins_path=#{@jenkins_path.inspect}," +
    " @timeout=#{@timeout.inspect}>," +
    " @http_open_timeout=#{@http_open_timeout.inspect}>," +
    " @http_read_timeout=#{@http_read_timeout.inspect}>"
end

#jobJenkinsApi::Client::Job

Creates an instance to the Job class by passing a reference to self

Returns:



168
169
170
# File 'lib/lhj/jenkins/client.rb', line 168

def job
  Lhj::JenkinsApi::Client::Job.new(self)
end

#nodeJenkinsApi::Client::Node

Creates an instance to the Node class by passing a reference to self

Returns:

  • (JenkinsApi::Client::Node)

    An object to Node subclass



184
185
186
# File 'lib/lhj/jenkins/client.rb', line 184

def node
  Lhj::JenkinsApi::Client::Node.new(self)
end

#pluginJenkinsApi::Client::PluginManager

Creates an instance to the PluginManager by passing a reference to self

Returns:

  • (JenkinsApi::Client::PluginManager)

    an object to PluginManager subclass



209
210
211
# File 'lib/lhj/jenkins/client.rb', line 209

def plugin
  Lhj::JenkinsApi::Client::PluginManager.new(self)
end

#post_config(url_prefix, xml) ⇒ String

Posts the given xml configuration to the url given

Parameters:

  • url_prefix (String)

    The prefix to be used in the URL

  • xml (String)

    The XML configuration to be sent to Jenkins

Returns:

  • (String)

    Response code returned from Jenkins



476
477
478
# File 'lib/lhj/jenkins/client.rb', line 476

def post_config(url_prefix, xml)
  post_data(url_prefix, xml, 'application/xml;charset=UTF-8')
end

#post_data(url_prefix, data, content_type) ⇒ Object



484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
# File 'lib/lhj/jenkins/client.rb', line 484

def post_data(url_prefix, data, content_type)
  retries = @crumb_max_retries
  begin
    refresh_crumbs

    request = Net::HTTP::Post.new("#{@jenkins_path}#{url_prefix}")
    @logger.debug "POST #{url_prefix}"
    request.body = data
    request.content_type = content_type
    if @crumbs_enabled
      request[@crumb["crumbRequestField"]] = @crumb["crumb"]
    end
    response = make_http_request(request)
    handle_exception(response)
  rescue Exceptions::ForbiddenException => e
    refresh_crumbs(true)

    if @crumbs_enabled
      @logger.info "Retrying: #{@crumb_max_retries - retries + 1} out of" +
                     " #{@crumb_max_retries} times..."
      retries -= 1

      if retries > 0
        retry
      else
        raise Exceptions::ForbiddenWithCrumb.new(@logger, e.message)
      end
    else
      raise
    end
  end
end

#post_json(url_prefix, json) ⇒ Object



480
481
482
# File 'lib/lhj/jenkins/client.rb', line 480

def post_json(url_prefix, json)
  post_data(url_prefix, json, 'application/json;charset=UTF-8')
end

#queueJenkinsApi::Client::BuildQueue

Creates an instance to the BuildQueue by passing a reference to self

Returns:

  • (JenkinsApi::Client::BuildQueue)

    An object to BuildQueue subclass



200
201
202
# File 'lib/lhj/jenkins/client.rb', line 200

def queue
  Lhj::JenkinsApi::Client::BuildQueue.new(self)
end

#rootJenkinsApi::Client::Root

Creates an instance of the Root class by passing a reference to self

Returns:

  • (JenkinsApi::Client::Root)

    An object of Root subclass



225
226
227
# File 'lib/lhj/jenkins/client.rb', line 225

def root
  Lhj::JenkinsApi::Client::Root.new(self)
end

#systemJenkinsApi::Client::System

Creates an instance to the System class by passing a reference to self

Returns:

  • (JenkinsApi::Client::System)

    An object to System subclass



176
177
178
# File 'lib/lhj/jenkins/client.rb', line 176

def system
  Lhj::JenkinsApi::Client::System.new(self)
end

#to_sString

Returns a string representing the class name

Returns:

  • (String)

    string representation of class name



233
234
235
# File 'lib/lhj/jenkins/client.rb', line 233

def to_s
  "#<JenkinsApi::Client>"
end

#use_crumbs?Boolean

Checks if Jenkins uses crumbs (i.e) the XSS disable option is checked in Jenkins’ security settings

Returns:

  • (Boolean)

    whether Jenkins uses crumbs or not



540
541
542
543
# File 'lib/lhj/jenkins/client.rb', line 540

def use_crumbs?
  response = api_get_request("", "tree=useCrumbs")
  response["useCrumbs"]
end

#use_security?Boolean

Checks if Jenkins uses security

Returns:

  • (Boolean)

    whether Jenkins uses security or not



549
550
551
552
# File 'lib/lhj/jenkins/client.rb', line 549

def use_security?
  response = api_get_request("", "tree=useSecurity")
  response["useSecurity"]
end

#userJenkinsApi::Client::User

Creates an instance of the User class by passing a reference to self

Returns:

  • (JenkinsApi::Client::User)

    An object of User subclass



217
218
219
# File 'lib/lhj/jenkins/client.rb', line 217

def user
  Lhj::JenkinsApi::Client::User.new(self)
end

#viewJenkinsApi::Client::View

Creates an instance to the View class by passing a reference to self

Returns:

  • (JenkinsApi::Client::View)

    An object to View subclass



192
193
194
# File 'lib/lhj/jenkins/client.rb', line 192

def view
  Lhj::JenkinsApi::Client::View.new(self)
end