Class: Publisher::IIS
- Inherits:
-
Object
- Object
- Publisher::IIS
- Defined in:
- lib/depengine/publisher/iis.rb
Instance Attribute Summary collapse
-
#http_read_timeout ⇒ Object
Returns the value of attribute http_read_timeout.
-
#protocol ⇒ Object
Returns the value of attribute protocol.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #appcmd(value) ⇒ Object
- #build(tag, env, version, value, application_name) ⇒ Object
- #deploy(version, iis_application_name, env) ⇒ Object
Instance Attribute Details
#http_read_timeout ⇒ Object
Returns the value of attribute http_read_timeout.
3 4 5 |
# File 'lib/depengine/publisher/iis.rb', line 3 def http_read_timeout @http_read_timeout end |
#protocol ⇒ Object
Returns the value of attribute protocol.
3 4 5 |
# File 'lib/depengine/publisher/iis.rb', line 3 def protocol @protocol end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/depengine/publisher/iis.rb', line 3 def url @url end |
Instance Method Details
#appcmd(value) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/depengine/publisher/iis.rb', line 37 def appcmd(value) Helper.validates_presence_of @url, 'IIS URL not set' Helper.validates_presence_of @protocol, 'Protocol not set' begin uri = URI(@protocol + '://' + @url) Net::HTTP.start(uri.host, uri.port) do |http| http.read_timeout = http_read_timeout request = Net::HTTP::Post.new uri.request_uri request.set_form_data('value' => value) request.content_type = 'application/x-www-form-urlencoded;charset=utf-8' http.request request do |response| response.read_body do |chunk| $log.writer.info "#{chunk}" end end end rescue => e $log.writer.error 'Error: while connecting to IIS Server' $log.writer.error "Request was: #{uri}" $log.writer.error e. exit 1 end end |
#build(tag, env, version, value, application_name) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/depengine/publisher/iis.rb', line 5 def build(tag, env, version, value, application_name) Helper.validates_presence_of @url, 'IIS URL not set' Helper.validates_presence_of @protocol, 'Protocol not set' iis_error = false begin uri = URI(@protocol + '://' + @url) Net::HTTP.start(uri.host, uri.port) do |http| http.read_timeout = http_read_timeout request = Net::HTTP::Post.new uri.request_uri request.set_form_data('tag' => tag, 'env' => env, 'version' => version, 'value' => value, 'application_name' => application_name) request.content_type = 'application/x-www-form-urlencoded;charset=utf-8' http.request request do |response| response.read_body do |chunk| if chunk.include?('### Error while executing') $log.writer.error 'Error executing build on IIS' iis_error = true end $log.writer.info "#{chunk}" end end end rescue => e $log.writer.error 'Error: while connecting to IIS Server' $log.writer.error "Request was: #{uri}" $log.writer.error e. exit 1 end fail if iis_error end |
#deploy(version, iis_application_name, env) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/depengine/publisher/iis.rb', line 62 def deploy(version, iis_application_name, env) Helper.validates_presence_of @url, 'IIS URL not set' Helper.validates_presence_of @protocol, 'Protocol not set' iis_error = false begin uri = URI(@protocol + '://' + @url) Net::HTTP.start(uri.host, uri.port) do |http| http.read_timeout = http_read_timeout request = Net::HTTP::Post.new uri.request_uri request.set_form_data('version' => version, 'application_name' => iis_application_name, 'env' => env) request.content_type = 'application/x-www-form-urlencoded;charset=utf-8' http.request request do |response| response.read_body do |chunk| if chunk.include?('### Error while executing') $log.writer.error 'Error executing deploy on IIS' iis_error = true end $log.writer.info "#{chunk}" end end end rescue => e $log.writer.error 'Error: while connecting to IIS Server' $log.writer.error "Request was: #{uri}" $log.writer.error e. exit 1 end fail if iis_error end |