jenkins2-api 1.0.2 → 1.0.3

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
  SHA1:
3
- metadata.gz: d6bfbc056dbe1bc9f82b4f9178e5f7892e06eee8
4
- data.tar.gz: 6c8d9cc4ebb65a8ce2b0498734858b2dfd0b7740
3
+ metadata.gz: f548e9981de4f48fd4bc914b6679f0432c0e1261
4
+ data.tar.gz: 843887cb04a375b2ae75eb09f9ac5f8d8e586c99
5
5
  SHA512:
6
- metadata.gz: 627027afdbe1cb6d91f7b2a0818d2b272cf375f14ee54ef94bf2ed50481dd7c49f879efa5dbe57e77bc92d417b9ab01cc4c454b5934126a5e787b7f2ee51c067
7
- data.tar.gz: 00e6d6f5c358c5664d05556224f6cdb1d208791609d15a6f63f1466924a44f4f035a836170a6a1cfe0c81e0f768a42cfbd187c3cadd3a5c57930c232d256a9e9
6
+ metadata.gz: 6b342762cced5d396f367b628d0a418fdc4bdc5a0a2dfe4785f3a99440b1084de0109cacf6d6771f736c1ff403f6bc0c77aa93999b9005c834dafb7422e6ba61
7
+ data.tar.gz: 2414d7813cd1bf923388b0aed30615b417a7161950705f844164a952cfd99d9c77b7917b13a4105ca3948b1bea7bcba8730a3518932ff171f028d7f4465b91aa
data/lib/client.rb CHANGED
@@ -28,24 +28,24 @@ module Jenkins2API
28
28
  end
29
29
  end
30
30
 
31
- # Job related endpoints. Creates new +Jenkins2API::Job+ instance
31
+ # Job related endpoints. Creates new +Jenkins2API::Endpoint::Job+ instance
32
32
  def job
33
- @job ||= Job.new(self)
33
+ @job ||= Endpoint::Job.new(self)
34
34
  end
35
35
 
36
- # Build related endpoints. Creates new +Jenkins2API::Build+ instance
36
+ # Build related endpoints. Creates new +Jenkins2API::Endpoint::Build+ instance
37
37
  def build
38
- @build ||= Build.new(self)
38
+ @build ||= Endpoint::Build.new(self)
39
39
  end
40
40
 
41
- # Artifact related endpoints. Creates new +Jenkins2API::Artifact+ instance
41
+ # Artifact related endpoints. Creates new +Jenkins2API::Endpoint::Artifact+ instance
42
42
  def artifact
43
- @artifact ||= Artifact.new(self)
43
+ @artifact ||= Endpoint::Artifact.new(self)
44
44
  end
45
45
 
46
- # Node/Computer related endpoints. Creates new +Jenkins2API::Node+ instance
46
+ # Node/Computer related endpoints. Creates new +Jenkins2API::Endpoint::Node+ instance
47
47
  def node
48
- @node ||= Node.new(self)
48
+ @node ||= Endpoint::Node.new(self)
49
49
  end
50
50
 
51
51
  # Creates and calls an API endpoint.
@@ -1,28 +1,30 @@
1
- require_relative '../endpoint'
1
+ require_relative 'base_endpoint'
2
2
 
3
3
  module Jenkins2API
4
- # This class contains all the calls to reach
5
- # Jenkins2 and obtain Artifact data
6
- class Artifact < Endpoint
7
- # Returns a list of all artifacts for a specific build
8
- #
9
- # Params:
10
- # +name+:: Job name
11
- # +build_id+:: ID of the build
12
- def all(name, build_id)
13
- @client.build.get(name)['artifacts']
14
- end
4
+ module Endpoint
5
+ # This class contains all the calls to reach
6
+ # Jenkins2 and obtain Artifact data
7
+ class Artifact < BaseEndpoint
8
+ # Returns a list of all artifacts for a specific build
9
+ #
10
+ # Params:
11
+ # +name+:: Job name
12
+ # +build_id+:: ID of the build
13
+ def all(name, build_id)
14
+ @client.build.get(name)['artifacts']
15
+ end
15
16
 
16
- # Download a specific artifact.
17
- #
18
- # Params:
19
- # +name+:: Job name
20
- # +build_id+:: ID of the build
21
- # +artifact+:: artifact +Hash+. this function uses only the +relativePath+ property
22
- #
23
- # Returns with the content of the artifact
24
- def get(name, build_id, artifact)
25
- @client.api_request(:get, "/job/#{name}/#{build_id}/artifact/#{artifact['relativePath']}", :raw)
17
+ # Download a specific artifact.
18
+ #
19
+ # Params:
20
+ # +name+:: Job name
21
+ # +build_id+:: ID of the build
22
+ # +artifact+:: artifact +Hash+. this function uses only the +relativePath+ property
23
+ #
24
+ # Returns with the content of the artifact
25
+ def get(name, build_id, artifact)
26
+ @client.api_request(:get, "/job/#{name}/#{build_id}/artifact/#{artifact['relativePath']}", :raw)
27
+ end
26
28
  end
27
29
  end
28
30
  end
@@ -0,0 +1,12 @@
1
+ module Jenkins2API
2
+ # Module to wrap all the endpoint
3
+ module Endpoint
4
+ # General methods for endpoints
5
+ class BaseEndpoint
6
+ # Stores the Jenkins2API::Client instance
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,64 +1,66 @@
1
- require_relative '../endpoint'
1
+ require_relative 'base_endpoint'
2
2
 
3
3
  module Jenkins2API
4
- # This class contains all the calls to reach
5
- # Jenkins2 and obtain Build data
6
- class Build < Endpoint
7
- # Get a specific build
8
- #
9
- # ==== Params:
10
- # +job_name+:: Name of the Job
11
- # +build_id+:: ID of the build
12
- def get(job_name, build_id)
13
- @client.api_request(:get, "/job/#{job_name}/#{build_id}")
14
- end
4
+ module Endpoint
5
+ # This class contains all the calls to reach
6
+ # Jenkins2 and obtain Build data
7
+ class Build < BaseEndpoint
8
+ # Get a specific build
9
+ #
10
+ # ==== Params:
11
+ # +job_name+:: Name of the Job
12
+ # +build_id+:: ID of the build
13
+ def get(job_name, build_id)
14
+ @client.api_request(:get, "/job/#{job_name}/#{build_id}")
15
+ end
15
16
 
16
- # Get the latest build
17
- #
18
- # ==== Params:
19
- # +job_name+:: Name of the Job
20
- def latest(name)
21
- @client.api_request(:get, "/job/#{name}/lastBuild")
22
- end
17
+ # Get the latest build
18
+ #
19
+ # ==== Params:
20
+ # +job_name+:: Name of the Job
21
+ def latest(name)
22
+ @client.api_request(:get, "/job/#{name}/lastBuild")
23
+ end
23
24
 
24
- # Get test report for a specific build
25
- #
26
- # ==== Params:
27
- # +name+:: Name of the Job
28
- # +build_id+:: ID of the build
29
- def test_results(name, build_id)
30
- @client.api_request(:get, "/job/#{name}/#{build_id}/testReport")
31
- end
25
+ # Get test report for a specific build
26
+ #
27
+ # ==== Params:
28
+ # +name+:: Name of the Job
29
+ # +build_id+:: ID of the build
30
+ def test_results(name, build_id)
31
+ @client.api_request(:get, "/job/#{name}/#{build_id}/testReport")
32
+ end
32
33
 
33
- # Get +console log+ for a specific build as text
34
- #
35
- # ==== Params:
36
- # +job_name+:: Name of the Job
37
- # +build_id+:: ID of the build
38
- #
39
- # Return an array of strings.
40
- # Each item in that array is a line from the log
41
- def logtext_lines(name, build_id)
42
- @client.api_request(:get, "/job/#{name}/#{build_id}/logText/progressiveText", :raw).split("\r\n")
43
- end
34
+ # Get +console log+ for a specific build as text
35
+ #
36
+ # ==== Params:
37
+ # +job_name+:: Name of the Job
38
+ # +build_id+:: ID of the build
39
+ #
40
+ # Return an array of strings.
41
+ # Each item in that array is a line from the log
42
+ def logtext_lines(name, build_id)
43
+ @client.api_request(:get, "/job/#{name}/#{build_id}/logText/progressiveText", :raw).split("\r\n")
44
+ end
44
45
 
45
- # Get the name of the slave where the build was executed
46
- #
47
- # ==== Params:
48
- # +name+:: Name of the Job
49
- # +build_id+:: ID of the build
50
- def slave_name(name, build_id)
51
- log = logtext_lines(name, build_id)
52
- relevant_line = log.select { |line| line.match(/^Running on /) }.first
46
+ # Get the name of the slave where the build was executed
47
+ #
48
+ # ==== Params:
49
+ # +name+:: Name of the Job
50
+ # +build_id+:: ID of the build
51
+ def slave_name(name, build_id)
52
+ log = logtext_lines(name, build_id)
53
+ relevant_line = log.select { |line| line.match(/^Running on /) }.first
53
54
 
54
- name = relevant_line.match(/^Running on (.*) in \//).captures.first rescue nil
55
+ name = relevant_line.match(/^Running on (.*) in \//).captures.first rescue nil
55
56
 
56
- if name.nil?
57
- relevant_line = log.select { |line| line.match(/Building remotely on/) }.first
58
- name = relevant_line.match(/Building remotely on (.*) in workspace/).captures.first
59
- end
57
+ if name.nil?
58
+ relevant_line = log.select { |line| line.match(/Building remotely on/) }.first
59
+ name = relevant_line.match(/Building remotely on (.*) in workspace/).captures.first
60
+ end
60
61
 
61
- name
62
+ name
63
+ end
62
64
  end
63
65
  end
64
66
  end
data/lib/endpoints/job.rb CHANGED
@@ -1,22 +1,24 @@
1
- require_relative '../endpoint'
1
+ require_relative 'base_endpoint'
2
2
 
3
3
  module Jenkins2API
4
- # This class contains all the calls to reach
5
- # Jenkins2 and obtain Build data
6
- class Job < Endpoint
7
- # Lists all available jobs
8
- def list
9
- @client.api_request(:get, "")['jobs']
10
- end
4
+ module Endpoint
5
+ # This class contains all the calls to reach
6
+ # Jenkins2 and obtain Build data
7
+ class Job < BaseEndpoint
8
+ # Lists all available jobs
9
+ def list
10
+ @client.api_request(:get, "")['jobs']
11
+ end
11
12
 
12
- # Get all available builds for a specific job
13
- #
14
- # ==== Params:
15
- # +name+:: Name of the Job
16
- #
17
- # Returns with an array of builds
18
- def builds(name)
19
- @client.api_request(:get, "/job/#{name}")['builds']
13
+ # Get all available builds for a specific job
14
+ #
15
+ # ==== Params:
16
+ # +name+:: Name of the Job
17
+ #
18
+ # Returns with an array of builds
19
+ def builds(name)
20
+ @client.api_request(:get, "/job/#{name}")['builds']
21
+ end
20
22
  end
21
23
  end
22
24
  end
@@ -1,14 +1,16 @@
1
- require_relative '../endpoint'
1
+ require_relative 'base_endpoint'
2
2
 
3
3
  module Jenkins2API
4
- # This class contains all the calls to reach
5
- # Jenkins2 and obtain Computer data
6
- class Node < Endpoint
7
- # List all available Computer
8
- #
9
- # Returns with slaves and masters also
10
- def all
11
- @client.api_request(:get, "/computer")
4
+ module Endpoint
5
+ # This class contains all the calls to reach
6
+ # Jenkins2 and obtain Computer data
7
+ class Node < BaseEndpoint
8
+ # List all available Computer
9
+ #
10
+ # Returns with slaves and masters also
11
+ def all
12
+ @client.api_request(:get, "/computer")
13
+ end
12
14
  end
13
15
  end
14
16
  end
data/lib/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Jenkins2API
2
2
  # Current version to publish
3
3
  # Gemspec also uses this constant
4
- VERSION = '1.0.2'
4
+ VERSION = '1.0.3'
5
5
  end
6
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jenkins2-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Balazs Nadasdi
@@ -38,8 +38,8 @@ files:
38
38
  - lib/commands/build.rb
39
39
  - lib/commands/job.rb
40
40
  - lib/commands/node.rb
41
- - lib/endpoint.rb
42
41
  - lib/endpoints/artifact.rb
42
+ - lib/endpoints/base_endpoint.rb
43
43
  - lib/endpoints/build.rb
44
44
  - lib/endpoints/job.rb
45
45
  - lib/endpoints/node.rb
data/lib/endpoint.rb DELETED
@@ -1,9 +0,0 @@
1
- module Jenkins2API
2
- # General methods for endpoints
3
- class Endpoint
4
- # Stores the Jenkins2API::Client instance
5
- def initialize(client)
6
- @client = client
7
- end
8
- end
9
- end