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 +4 -4
- data/lib/client.rb +8 -8
- data/lib/endpoints/artifact.rb +24 -22
- data/lib/endpoints/base_endpoint.rb +12 -0
- data/lib/endpoints/build.rb +54 -52
- data/lib/endpoints/job.rb +18 -16
- data/lib/endpoints/node.rb +11 -9
- data/lib/version.rb +1 -1
- metadata +2 -2
- data/lib/endpoint.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f548e9981de4f48fd4bc914b6679f0432c0e1261
|
4
|
+
data.tar.gz: 843887cb04a375b2ae75eb09f9ac5f8d8e586c99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
data/lib/endpoints/artifact.rb
CHANGED
@@ -1,28 +1,30 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative 'base_endpoint'
|
2
2
|
|
3
3
|
module Jenkins2API
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
data/lib/endpoints/build.rb
CHANGED
@@ -1,64 +1,66 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative 'base_endpoint'
|
2
2
|
|
3
3
|
module Jenkins2API
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
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
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
-
|
55
|
+
name = relevant_line.match(/^Running on (.*) in \//).captures.first rescue nil
|
55
56
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
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
|
-
|
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 '
|
1
|
+
require_relative 'base_endpoint'
|
2
2
|
|
3
3
|
module Jenkins2API
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
data/lib/endpoints/node.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
|
-
require_relative '
|
1
|
+
require_relative 'base_endpoint'
|
2
2
|
|
3
3
|
module Jenkins2API
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
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.
|
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
|