jenkins_shell 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 62684f8fbf197dfe7f84b10e6f1360da5bf35ab0eb27007c8b13a6e284441679
4
- data.tar.gz: 6dbcab48ec5d32b1c1a84c50c96f242cc40d7b7197a507f4e693be51e63f3eb4
3
+ metadata.gz: 8b75e3e5e33e080ce9171c0b0ee8db6516c0ac65caf40f6439f2ab29d46a8f48
4
+ data.tar.gz: 8d6e7aa40827b25a6c0ae21be8189aa91e2117100578a033dadfbb8d9adab657
5
5
  SHA512:
6
- metadata.gz: a1ee32220ec85235db0fd0c0e0251d66afc9dcf1b3d6a6882653b0811586c3c4590bef39bc3d1ae0fc2765176a0861f4ba7c236704d82a386de01d2ac861e86c
7
- data.tar.gz: d6ef8f8919d86791d3c1ffe7e393fe1e9df2c68629e04f9e41d42ab08788ccee98ad776d1694fb967f928e1d16699de72f087b749333a08ccddad3c16f33d28d
6
+ metadata.gz: ac037325b5a840fb70578e5dc11705b22d21653d0f26e8d8cae5afb550220d483076d4e992c137cbc7260fe5626a3a3d6eb0443fc8acf79caeae6bce598aa6fa
7
+ data.tar.gz: 317538957c5d1f4d0d4e16f170926d0e67cca4612652cf1acaeba0406030fac8cd3096e006274f72e359d16d4fc8ad08c8e5224ba2c919e0c85394ae81c9b4e6
data/bin/jsh CHANGED
@@ -115,6 +115,9 @@ rescue Interrupt
115
115
  rescue Errno::EPIPE
116
116
  # Do nothing. This can happen if piping to another program such as
117
117
  # less. Usually if less is closed before we're done with STDOUT.
118
+ rescue JenkinsShell::Error => e
119
+ puts e.message
120
+ exit JShExit::EXCEPTION
118
121
  rescue Exception => e
119
122
  $stderr.puts "Oops! Looks like an error has occured! If the " \
120
123
  "error persists, file a bug at:".wrap
@@ -0,0 +1,5 @@
1
+ class JenkinsShell::Error::ConnectionRefused < JenkinsShell::Error
2
+ def initialize(host, port)
3
+ super("Connection to #{host}:#{port} refused")
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class JenkinsShell::Error::InvalidHTMLReceived < JenkinsShell::Error
2
+ def initialize
3
+ super("Invalid HTML received")
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class JenkinsShell::Error < RuntimeError
2
+ end
3
+
4
+ require "jenkins_shell/error/connection_refused"
5
+ require "jenkins_shell/error/invalid_html_received"
data/lib/jenkins_shell.rb CHANGED
@@ -26,14 +26,24 @@ class JenkinsShell
26
26
  gs = "println(\"cmd /c cd #{fix} && #{cmd}\".execute().text)"
27
27
  enc = URI::encode(URI::encode(gs), "&()/").gsub("%20", "+")
28
28
 
29
- # Establish connection and send script
30
- http = Net::HTTP.new(@host, @port)
31
- xml = REXML::Document.new(
32
- http.post("/script", "script=#{enc}").body
33
- )
34
-
35
- # Parse response and return script output
36
- return xml.get_elements("html/body/div/div/pre")[1].text
29
+ begin
30
+ # Establish connection and send script
31
+ http = Net::HTTP.new(@host, @port)
32
+ xml = REXML::Document.new(
33
+ http.post("/script", "script=#{enc}").body
34
+ )
35
+
36
+ # Parse response and return script output
37
+ return xml.get_elements("html/body/div/div/pre")[1].text
38
+ rescue Errno::ECONNREFUSED
39
+ raise JenkinsShell::Error::ConnectionRefused.new(
40
+ @host,
41
+ @port
42
+ )
43
+ rescue REXML::ParseException
44
+ raise JenkinsShell::Error::InvalidHTMLReceived.new
45
+ end
46
+ return ""
37
47
  end
38
48
 
39
49
  def initialize(host, port = 8080)
@@ -50,3 +60,5 @@ class JenkinsShell
50
60
  return ""
51
61
  end
52
62
  end
63
+
64
+ require "jenkins_shell/error"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jenkins_shell
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Whittaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-14 00:00:00.000000000 Z
11
+ date: 2018-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -80,6 +80,9 @@ extra_rdoc_files: []
80
80
  files:
81
81
  - bin/jsh
82
82
  - lib/jenkins_shell.rb
83
+ - lib/jenkins_shell/error.rb
84
+ - lib/jenkins_shell/error/connection_refused.rb
85
+ - lib/jenkins_shell/error/invalid_html_received.rb
83
86
  - lib/jenkins_shell/wish/cd_wish.rb
84
87
  - lib/jenkins_shell/wish/cmd_wish.rb
85
88
  - lib/jenkins_shell/wish/ls_wish.rb