jenkins2-api 0.0.5 → 1.0.1
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/README.md +124 -0
- data/lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce596bcac88f03c2226d88a297f7922760a599f7
|
4
|
+
data.tar.gz: 143eb32b438a562b5066f028264f5c68164799de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 455bb82a3071c90be0c389484027642d0559ab6f57cf98ee45cbd990e0e3eab8451298a792ad2f885dc427fcb278f96445ec8bbde8a33fccf85fa266b69c8b52
|
7
|
+
data.tar.gz: b6604ce550b178f1837ca48cc2cda2557dcdb01998cfe3eaff05d73d80b16045f7911ddf9490e38b948d71bfe2b19d8a0e5f4447db4fdaca500182e537d59845
|
data/README.md
CHANGED
@@ -0,0 +1,124 @@
|
|
1
|
+
[](https://badge.fury.io/rb/jenkins2-api)
|
2
|
+
|
3
|
+
# API Client for Jenkins2
|
4
|
+
|
5
|
+
## Install
|
6
|
+
|
7
|
+
```
|
8
|
+
gem install jenkins2-api
|
9
|
+
```
|
10
|
+
|
11
|
+
## Executable
|
12
|
+
|
13
|
+
You can specify server and credentials with parameters:
|
14
|
+
|
15
|
+
```
|
16
|
+
--password
|
17
|
+
--username
|
18
|
+
--server
|
19
|
+
```
|
20
|
+
|
21
|
+
Or with environment variables:
|
22
|
+
|
23
|
+
```
|
24
|
+
JENKINS_SERVER=''
|
25
|
+
JENKINS_USERNAME=''
|
26
|
+
JENKINS_PASSWORD=''
|
27
|
+
```
|
28
|
+
|
29
|
+
Password can be a password or an API token from `/user/{user}/configure`
|
30
|
+
|
31
|
+
### List computers / nodes
|
32
|
+
|
33
|
+
```
|
34
|
+
# List all nodes
|
35
|
+
jenkins2api node all
|
36
|
+
|
37
|
+
# Only slaves
|
38
|
+
jenkins2api node slaves
|
39
|
+
```
|
40
|
+
|
41
|
+
### Get the name of the slave where a build was executed
|
42
|
+
|
43
|
+
```
|
44
|
+
jenkins2api build slave-name jobname buildid
|
45
|
+
```
|
46
|
+
|
47
|
+
If you build slave names contain an AWS EC2 ID, you you add `--ec2id` parameter to match for it
|
48
|
+
and then it will print out only the ec2 instance id.
|
49
|
+
|
50
|
+
```
|
51
|
+
jenkins2api build slave-name jobname buildid --ec2id
|
52
|
+
```
|
53
|
+
|
54
|
+
## Ruby side
|
55
|
+
|
56
|
+
All response are a generic Jenkins response. There are no wrapper classes around them.
|
57
|
+
|
58
|
+
Create a new client:
|
59
|
+
|
60
|
+
```
|
61
|
+
require 'jenkins2-api'
|
62
|
+
|
63
|
+
client = Jenkins2API::Client.new(
|
64
|
+
:server => 'http://jenkins.example.com/',
|
65
|
+
:username => 'myusername',
|
66
|
+
:password => 'myapitoken'
|
67
|
+
)
|
68
|
+
```
|
69
|
+
|
70
|
+
To list all the available jobs:
|
71
|
+
|
72
|
+
```
|
73
|
+
jobs = client.job.list
|
74
|
+
jobs.each do |job|
|
75
|
+
puts "[%10s] #{job['name']}" % [job['color']]
|
76
|
+
end
|
77
|
+
```
|
78
|
+
|
79
|
+
List all node:
|
80
|
+
|
81
|
+
```
|
82
|
+
nodes = client.node.all
|
83
|
+
puts "Total Executors: #{nodes['totalExecutors']}"
|
84
|
+
puts "Busy Executors: #{nodes['busyExecutors']}"
|
85
|
+
|
86
|
+
puts "Executors:"
|
87
|
+
nodes['computer'].each do |computer|
|
88
|
+
type = 'slave'
|
89
|
+
type = 'master' if computer['_class'] == 'hudson.model.Hudson$MasterComputer'
|
90
|
+
puts " [%7s] #{computer['displayName']}" % [type]
|
91
|
+
end
|
92
|
+
```
|
93
|
+
|
94
|
+
Get a specific job's latest build information:
|
95
|
+
|
96
|
+
```
|
97
|
+
build = client.build.latest('my-job')
|
98
|
+
|
99
|
+
puts "Latest build: #{build['id']}"
|
100
|
+
puts "Result: #{build['result']}"
|
101
|
+
puts "URL: #{build['url']}"
|
102
|
+
logfiles = build['artifacts'].select { |artifact| artifact['fileName'].match(/.*\.xml$/) }
|
103
|
+
|
104
|
+
slave_name = client.build.slave_name('my-job', build['id'])
|
105
|
+
|
106
|
+
puts "Build on: #{slave_name}"
|
107
|
+
```
|
108
|
+
|
109
|
+
Process junit reports:
|
110
|
+
|
111
|
+
```
|
112
|
+
failed_tests = []
|
113
|
+
logfiles.each do |file|
|
114
|
+
results = Nokogiri::XML(client.artifact.get('my-job', build['id'], file))
|
115
|
+
failed_tests += results.xpath('//testcase').select do |testcase|
|
116
|
+
!testcase.children.empty?
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
puts "Failed tests:" unless failed_tests.empty?
|
121
|
+
failed_tests.each do |failed|
|
122
|
+
puts " [✘] #{failed['name']} on #{failed['classname']}"
|
123
|
+
end
|
124
|
+
```
|
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:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Balazs Nadasdi
|
@@ -45,7 +45,7 @@ files:
|
|
45
45
|
- lib/jenkins2-api.rb
|
46
46
|
- lib/thor_command.rb
|
47
47
|
- lib/version.rb
|
48
|
-
homepage: https://github.
|
48
|
+
homepage: https://yitsushi.github.io/jenkins2-api/
|
49
49
|
licenses:
|
50
50
|
- MIT
|
51
51
|
metadata: {}
|