jenkins_api_client 0.1.1 → 0.2.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.
- data/.gitignore +29 -0
- data/CHANGELOG.rdoc +3 -0
- data/Gemfile +2 -0
- data/README.rdoc +9 -0
- data/Rakefile +4 -4
- data/bin/jenkinscli +5 -0
- data/lib/jenkins_api_client.rb +2 -1
- data/lib/jenkins_api_client/cli/base.rb +49 -0
- data/lib/jenkins_api_client/cli/job.rb +109 -0
- data/lib/jenkins_api_client/version.rb +1 -1
- metadata +33 -59
data/.gitignore
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
# bundler
|
|
3
|
+
.bundle
|
|
4
|
+
|
|
5
|
+
# jeweler generated
|
|
6
|
+
pkg
|
|
7
|
+
|
|
8
|
+
# test script
|
|
9
|
+
test
|
|
10
|
+
|
|
11
|
+
# simplecov code coverage directory
|
|
12
|
+
coverage
|
|
13
|
+
|
|
14
|
+
# Yard doc
|
|
15
|
+
doc
|
|
16
|
+
.yardoc
|
|
17
|
+
#
|
|
18
|
+
Gemfile.lock
|
|
19
|
+
|
|
20
|
+
# MacOS:
|
|
21
|
+
.DS_Store
|
|
22
|
+
|
|
23
|
+
# vim, emacs, textmate
|
|
24
|
+
*~
|
|
25
|
+
\#*
|
|
26
|
+
.\#*
|
|
27
|
+
*.tmproj
|
|
28
|
+
tmtags
|
|
29
|
+
*.swp
|
data/CHANGELOG.rdoc
CHANGED
data/Gemfile
CHANGED
data/README.rdoc
CHANGED
|
@@ -122,6 +122,15 @@ with 'failure' as the threshold, and also chain three jobs in parallel.
|
|
|
122
122
|
raise "Unable to build job: #{job}" unless code == 302
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
=== Using with command line
|
|
126
|
+
Command line interface is supported only from version 0.2.0.
|
|
127
|
+
See help using <tt>jenkinscli help</tt>
|
|
128
|
+
|
|
129
|
+
There are three ways for authentication using command line interface
|
|
130
|
+
1. Passing all credentials and server information using command line parameters
|
|
131
|
+
2. Passing the credentials file as the command line parameter
|
|
132
|
+
3. Having the credentials file in the default location <tt>HOME/.jenkins_api_client/login.yml</tt>
|
|
133
|
+
|
|
125
134
|
=== Debug
|
|
126
135
|
|
|
127
136
|
The call to client initialization accepts a debug parameter. If it is set to <tt>true</tt> it will print
|
data/Rakefile
CHANGED
|
@@ -9,6 +9,9 @@ Jeweler::Tasks.new do |gemspec|
|
|
|
9
9
|
gemspec.platform = Gem::Platform::RUBY
|
|
10
10
|
gemspec.date = Time.now.utc.strftime("%Y-%m-%d")
|
|
11
11
|
gemspec.require_path = 'lib'
|
|
12
|
+
gemspec.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
|
|
13
|
+
gemspec.files = `git ls-files`.split("\n")
|
|
14
|
+
gemspec.extra_rdoc_files = ['CHANGELOG.rdoc', 'LICENSE', 'README.rdoc']
|
|
12
15
|
gemspec.authors = [ 'Kannan Manickam' ]
|
|
13
16
|
gemspec.email = [ 'arangamani.kannan@gmail.com' ]
|
|
14
17
|
gemspec.homepage = 'https://github.com/arangamani/jenkins_api_client'
|
|
@@ -16,9 +19,6 @@ Jeweler::Tasks.new do |gemspec|
|
|
|
16
19
|
gemspec.description = %{
|
|
17
20
|
This is a simple and easy-to-use Jenkins Api client with features focused on
|
|
18
21
|
automating Job configuration programaticaly and so forth}
|
|
22
|
+
gemspec.test_files = `git ls-files -- {spec}/*`.split("\n")
|
|
19
23
|
gemspec.rubygems_version = '1.8.17'
|
|
20
|
-
gemspec.add_runtime_dependency 'json'
|
|
21
|
-
gemspec.add_development_dependency 'rake', '0.8.7'
|
|
22
|
-
gemspec.add_development_dependency 'activesupport'
|
|
23
|
-
gemspec.add_development_dependency 'bundler'
|
|
24
24
|
end
|
data/bin/jenkinscli
ADDED
data/lib/jenkins_api_client.rb
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
Dir[File.dirname(__FILE__) + '/jenkins_api_client/*.rb'].each {|file| require file }
|
|
2
|
+
Dir[File.dirname(__FILE__) + '/jenkins_api_client/cli/*.rb'].each {|file| require file }
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2012 Kannan Manickam <arangamani.kannan@gmail.com>
|
|
3
|
+
#
|
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
# furnished to do so, subject to the following conditions:
|
|
10
|
+
#
|
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
|
12
|
+
# all copies or substantial portions of the Software.
|
|
13
|
+
#
|
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
20
|
+
# THE SOFTWARE.
|
|
21
|
+
#
|
|
22
|
+
|
|
23
|
+
require 'thor'
|
|
24
|
+
require 'thor/group'
|
|
25
|
+
require "#{File.dirname(__FILE__)}/../client.rb"
|
|
26
|
+
require "#{File.dirname(__FILE__)}/job.rb"
|
|
27
|
+
|
|
28
|
+
module JenkinsApi
|
|
29
|
+
module CLI
|
|
30
|
+
|
|
31
|
+
class Base < Thor
|
|
32
|
+
map "-v" => :version
|
|
33
|
+
|
|
34
|
+
desc "version", "Shows current version"
|
|
35
|
+
def version
|
|
36
|
+
puts JenkinsApi::Client::VERSION
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
JenkinsApi::CLI::Base.register(
|
|
44
|
+
JenkinsApi::CLI::Job,
|
|
45
|
+
'job',
|
|
46
|
+
'job [subcommand]',
|
|
47
|
+
'Provides functions to access the job interface of Jenkins CI server'
|
|
48
|
+
)
|
|
49
|
+
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2012 Kannan Manickam <arangamani.kannan@gmail.com>
|
|
3
|
+
#
|
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
# furnished to do so, subject to the following conditions:
|
|
10
|
+
#
|
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
|
12
|
+
# all copies or substantial portions of the Software.
|
|
13
|
+
#
|
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
20
|
+
# THE SOFTWARE.
|
|
21
|
+
#
|
|
22
|
+
|
|
23
|
+
require File.expand_path('../base', __FILE__)
|
|
24
|
+
require 'fileutils'
|
|
25
|
+
|
|
26
|
+
module JenkinsApi
|
|
27
|
+
module CLI
|
|
28
|
+
|
|
29
|
+
class Job < Thor
|
|
30
|
+
include Thor::Actions
|
|
31
|
+
class_option :username, :aliases => "-u", :desc => "Name of Jenkins user"
|
|
32
|
+
class_option :password, :aliases => "-p", :desc => "Password of Jenkins user"
|
|
33
|
+
class_option :password_base64, :aliases => "-b", :desc => "Base 64 encoded password of Jenkins user"
|
|
34
|
+
class_option :server_ip, :aliases => "-s", :desc => "Jenkins server IP address"
|
|
35
|
+
class_option :server_port, :aliases => "-o", :desc => "Jenkins server port"
|
|
36
|
+
class_option :creds_file, :aliases => "-c", :desc => "Credentials file for communicating with Jenkins server"
|
|
37
|
+
|
|
38
|
+
no_tasks {
|
|
39
|
+
def setup
|
|
40
|
+
if options[:username] && options[:server_ip] && (options[:password] || options[:password_base64])
|
|
41
|
+
creds = options
|
|
42
|
+
elsif options[:creds_file]
|
|
43
|
+
creds = YAML.load_file(File.expand_path(options[:creds_file], __FILE__))
|
|
44
|
+
elsif File.exist?("#{ENV['HOME']}/.jenkins_api_client/login.yml")
|
|
45
|
+
creds = YAML.load_file(File.expand_path("#{ENV['HOME']}/.jenkins_api_client/login.yml", __FILE__))
|
|
46
|
+
else
|
|
47
|
+
say "Credentials are not set. Please pass them as parameters or set them in the default credentials file", :red
|
|
48
|
+
end
|
|
49
|
+
JenkinsApi::Client.new(creds)
|
|
50
|
+
end
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
desc "test", "Test job"
|
|
54
|
+
def test
|
|
55
|
+
#invoke :creds
|
|
56
|
+
setup
|
|
57
|
+
puts "test: #{options[:username]}"
|
|
58
|
+
#puts self.options[:username] if self.options[:username]
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
desc "list", "List jobs"
|
|
62
|
+
method_option :filter, :aliases => "-f", :desc => "Regular expression to filter jobs"
|
|
63
|
+
def list
|
|
64
|
+
@client = setup
|
|
65
|
+
if options[:filter]
|
|
66
|
+
puts @client.job.list(options[:filter])
|
|
67
|
+
else
|
|
68
|
+
puts @client.job.list_all
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
desc "build JOB", "Build a job"
|
|
73
|
+
def build(job)
|
|
74
|
+
@client = setup
|
|
75
|
+
@client.job.build(job)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
desc "status JOB", "Get the current build status of a job"
|
|
79
|
+
def status(job)
|
|
80
|
+
@client = setup
|
|
81
|
+
puts @client.job.get_current_build_status(job)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
desc "listrunning", "List running jobs"
|
|
85
|
+
def listrunning
|
|
86
|
+
@client = setup
|
|
87
|
+
puts @client.job.list_running
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
desc "delete JOB", "Delete the job"
|
|
91
|
+
def delete(job)
|
|
92
|
+
@client = setup
|
|
93
|
+
puts @client.job.delete(job)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
desc "restrict JOB", "Restricts a job to a specific node"
|
|
97
|
+
method_option :node, :aliases => "-n", :desc => "Node to be restricted to"
|
|
98
|
+
def restrict(job)
|
|
99
|
+
@client = setup
|
|
100
|
+
if options[:node]
|
|
101
|
+
@client.job.restrict_to_node(job, options[:node])
|
|
102
|
+
else
|
|
103
|
+
say "You need to specify the node to be restricted to.", :red
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jenkins_api_client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-
|
|
12
|
+
date: 2012-11-02 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: nokogiri
|
|
@@ -44,62 +44,30 @@ dependencies:
|
|
|
44
44
|
- !ruby/object:Gem::Version
|
|
45
45
|
version: 3.2.8
|
|
46
46
|
- !ruby/object:Gem::Dependency
|
|
47
|
-
name:
|
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
|
49
|
-
none: false
|
|
50
|
-
requirements:
|
|
51
|
-
- - ~>
|
|
52
|
-
- !ruby/object:Gem::Version
|
|
53
|
-
version: 1.2.1
|
|
54
|
-
type: :development
|
|
55
|
-
prerelease: false
|
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
-
none: false
|
|
58
|
-
requirements:
|
|
59
|
-
- - ~>
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: 1.2.1
|
|
62
|
-
- !ruby/object:Gem::Dependency
|
|
63
|
-
name: jeweler
|
|
47
|
+
name: thor
|
|
64
48
|
requirement: !ruby/object:Gem::Requirement
|
|
65
49
|
none: false
|
|
66
50
|
requirements:
|
|
67
51
|
- - ~>
|
|
68
52
|
- !ruby/object:Gem::Version
|
|
69
|
-
version:
|
|
70
|
-
type: :
|
|
53
|
+
version: 0.16.0
|
|
54
|
+
type: :runtime
|
|
71
55
|
prerelease: false
|
|
72
56
|
version_requirements: !ruby/object:Gem::Requirement
|
|
73
57
|
none: false
|
|
74
58
|
requirements:
|
|
75
59
|
- - ~>
|
|
76
60
|
- !ruby/object:Gem::Version
|
|
77
|
-
version:
|
|
61
|
+
version: 0.16.0
|
|
78
62
|
- !ruby/object:Gem::Dependency
|
|
79
|
-
name:
|
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
|
81
|
-
none: false
|
|
82
|
-
requirements:
|
|
83
|
-
- - ~>
|
|
84
|
-
- !ruby/object:Gem::Version
|
|
85
|
-
version: 3.1.3
|
|
86
|
-
type: :development
|
|
87
|
-
prerelease: false
|
|
88
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
89
|
-
none: false
|
|
90
|
-
requirements:
|
|
91
|
-
- - ~>
|
|
92
|
-
- !ruby/object:Gem::Version
|
|
93
|
-
version: 3.1.3
|
|
94
|
-
- !ruby/object:Gem::Dependency
|
|
95
|
-
name: simplecov
|
|
63
|
+
name: json
|
|
96
64
|
requirement: !ruby/object:Gem::Requirement
|
|
97
65
|
none: false
|
|
98
66
|
requirements:
|
|
99
67
|
- - ! '>='
|
|
100
68
|
- !ruby/object:Gem::Version
|
|
101
69
|
version: '0'
|
|
102
|
-
type: :
|
|
70
|
+
type: :runtime
|
|
103
71
|
prerelease: false
|
|
104
72
|
version_requirements: !ruby/object:Gem::Requirement
|
|
105
73
|
none: false
|
|
@@ -108,55 +76,55 @@ dependencies:
|
|
|
108
76
|
- !ruby/object:Gem::Version
|
|
109
77
|
version: '0'
|
|
110
78
|
- !ruby/object:Gem::Dependency
|
|
111
|
-
name:
|
|
79
|
+
name: bundler
|
|
112
80
|
requirement: !ruby/object:Gem::Requirement
|
|
113
81
|
none: false
|
|
114
82
|
requirements:
|
|
115
|
-
- -
|
|
83
|
+
- - ~>
|
|
116
84
|
- !ruby/object:Gem::Version
|
|
117
|
-
version:
|
|
118
|
-
type: :
|
|
85
|
+
version: 1.2.1
|
|
86
|
+
type: :development
|
|
119
87
|
prerelease: false
|
|
120
88
|
version_requirements: !ruby/object:Gem::Requirement
|
|
121
89
|
none: false
|
|
122
90
|
requirements:
|
|
123
|
-
- -
|
|
91
|
+
- - ~>
|
|
124
92
|
- !ruby/object:Gem::Version
|
|
125
|
-
version:
|
|
93
|
+
version: 1.2.1
|
|
126
94
|
- !ruby/object:Gem::Dependency
|
|
127
|
-
name:
|
|
95
|
+
name: jeweler
|
|
128
96
|
requirement: !ruby/object:Gem::Requirement
|
|
129
97
|
none: false
|
|
130
98
|
requirements:
|
|
131
|
-
- -
|
|
99
|
+
- - ~>
|
|
132
100
|
- !ruby/object:Gem::Version
|
|
133
|
-
version:
|
|
101
|
+
version: 1.6.4
|
|
134
102
|
type: :development
|
|
135
103
|
prerelease: false
|
|
136
104
|
version_requirements: !ruby/object:Gem::Requirement
|
|
137
105
|
none: false
|
|
138
106
|
requirements:
|
|
139
|
-
- -
|
|
107
|
+
- - ~>
|
|
140
108
|
- !ruby/object:Gem::Version
|
|
141
|
-
version:
|
|
109
|
+
version: 1.6.4
|
|
142
110
|
- !ruby/object:Gem::Dependency
|
|
143
|
-
name:
|
|
111
|
+
name: builder
|
|
144
112
|
requirement: !ruby/object:Gem::Requirement
|
|
145
113
|
none: false
|
|
146
114
|
requirements:
|
|
147
|
-
- -
|
|
115
|
+
- - ~>
|
|
148
116
|
- !ruby/object:Gem::Version
|
|
149
|
-
version:
|
|
117
|
+
version: 3.1.3
|
|
150
118
|
type: :development
|
|
151
119
|
prerelease: false
|
|
152
120
|
version_requirements: !ruby/object:Gem::Requirement
|
|
153
121
|
none: false
|
|
154
122
|
requirements:
|
|
155
|
-
- -
|
|
123
|
+
- - ~>
|
|
156
124
|
- !ruby/object:Gem::Version
|
|
157
|
-
version:
|
|
125
|
+
version: 3.1.3
|
|
158
126
|
- !ruby/object:Gem::Dependency
|
|
159
|
-
name:
|
|
127
|
+
name: simplecov
|
|
160
128
|
requirement: !ruby/object:Gem::Requirement
|
|
161
129
|
none: false
|
|
162
130
|
requirements:
|
|
@@ -178,18 +146,24 @@ description: ! '
|
|
|
178
146
|
automating Job configuration programaticaly and so forth'
|
|
179
147
|
email:
|
|
180
148
|
- arangamani.kannan@gmail.com
|
|
181
|
-
executables:
|
|
149
|
+
executables:
|
|
150
|
+
- jenkinscli
|
|
182
151
|
extensions: []
|
|
183
152
|
extra_rdoc_files:
|
|
153
|
+
- CHANGELOG.rdoc
|
|
184
154
|
- README.rdoc
|
|
185
155
|
files:
|
|
156
|
+
- .gitignore
|
|
186
157
|
- CHANGELOG.rdoc
|
|
187
158
|
- Gemfile
|
|
188
159
|
- LICENCE
|
|
189
160
|
- README.rdoc
|
|
190
161
|
- Rakefile
|
|
162
|
+
- bin/jenkinscli
|
|
191
163
|
- config/login.yml.example
|
|
192
164
|
- lib/jenkins_api_client.rb
|
|
165
|
+
- lib/jenkins_api_client/cli/base.rb
|
|
166
|
+
- lib/jenkins_api_client/cli/job.rb
|
|
193
167
|
- lib/jenkins_api_client/client.rb
|
|
194
168
|
- lib/jenkins_api_client/exceptions.rb
|
|
195
169
|
- lib/jenkins_api_client/job.rb
|
|
@@ -212,7 +186,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
212
186
|
version: '0'
|
|
213
187
|
segments:
|
|
214
188
|
- 0
|
|
215
|
-
hash:
|
|
189
|
+
hash: 2332251850265397219
|
|
216
190
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
191
|
none: false
|
|
218
192
|
requirements:
|