Class: Jenkins::Plugin::Tools::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/jenkins/plugin/tools/server.rb

Instance Method Summary collapse

Constructor Details

#initialize(spec, workdir, war = nil, port) ⇒ Server

Returns a new instance of Server.



12
13
14
15
16
17
18
# File 'lib/jenkins/plugin/tools/server.rb', line 12

def initialize(spec, workdir, war = nil, port)
  @spec = spec
  @workdir = workdir
  @plugindir = "#{workdir}/plugins"
  @war = war || Jenkins::War::LOCATION
  @port = port
end

Instance Method Details

#run!Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/jenkins/plugin/tools/server.rb', line 20

def run!
  FileUtils.mkdir_p(@plugindir)
  loadpath = Jenkins::Plugin::Tools::Loadpath.new
  manifest = Jenkins::Plugin::Tools::Manifest.new(@spec)
  resolver = Jenkins::Plugin::Tools::Resolver.new(@spec, @plugindir)

  resolver.resolve!

  # generate the plugin manifest
  File.open("#{@plugindir}/#{@spec.name}.hpl",mode="w+") do |f|
    manifest.write_hpl(f, loadpath)
  end

  # cancel out the effect of being invoked from Bundler
  # otherwise this will affect Bundler that we run from inside Jenkins run by "jpi server"
  ENV['BUNDLE_GEMFILE'] = nil
  ENV['BUNDLE_BIN_PATH'] = nil
  ENV['RUBYOPT'] = nil

  # execute Jenkins
  args = []
  args << "java"
  args << "-Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n"
  args << "-DJENKINS_HOME=#{@workdir}"
  args << "-Dstapler.trace=true"
  args << "-Djenkins.development-mode=true"
  args << "-Ddebug.YUI=true"
  args << ENV['JAVA_OPTS'] if ENV.key? 'JAVA_OPTS'
  args << "-jar"
  args << @war
  args << ENV['JENKINS_OPTS'] if ENV.key? 'JENKINS_OPTS'
  unless ENV.key?('JENKINS_OPTS') && !ENV['JENKINS_OPTS'].index("--httpPort=").nil?
    args << "--httpPort=#{@port}"
  end
  exec args.join(' ')
end