jenkins_launcher 0.0.2 → 0.1.0
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/CHANGELOG.md +9 -1
- data/config/sample-git.yml +7 -0
- data/config/sample-svn.yml +8 -0
- data/config/sample.yml +2 -2
- data/lib/jenkins_launcher/api_interface.rb +1 -0
- data/lib/jenkins_launcher/cli.rb +38 -10
- data/lib/jenkins_launcher/config_loader.rb +16 -2
- data/lib/jenkins_launcher/core_ext/string.rb +29 -0
- data/lib/jenkins_launcher/core_ext.rb +23 -0
- data/lib/jenkins_launcher/version.rb +2 -2
- data/lib/jenkins_launcher.rb +1 -0
- metadata +5 -1
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,17 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
=========
|
3
3
|
|
4
|
+
v0.1.0 [13-JAN-2013]
|
5
|
+
---------------------
|
6
|
+
* Added options for source control management: Git and Subversion.
|
7
|
+
* Added colors in printing messages on console.
|
8
|
+
* Added command `console` to print the console output of the recent build of the job.
|
9
|
+
* The `shell_command` option is renamed to `script` to match Travis CI.
|
10
|
+
* Some minor tweaks to the implementation.
|
11
|
+
|
4
12
|
v0.0.2 [13-JAN-2013]
|
5
13
|
---------------------
|
6
|
-
*
|
14
|
+
* Fixed a bug where the last few lines of console output was missed while printing the progressive console output.
|
7
15
|
|
8
16
|
v0.0.1 [12-JAN-2013]
|
9
17
|
---------------------
|
data/config/sample.yml
CHANGED
data/lib/jenkins_launcher/cli.rb
CHANGED
@@ -22,6 +22,7 @@
|
|
22
22
|
|
23
23
|
require File.expand_path('../config_loader', __FILE__)
|
24
24
|
require File.expand_path('../api_interface', __FILE__)
|
25
|
+
require File.expand_path('../core_ext', __FILE__)
|
25
26
|
require 'thor'
|
26
27
|
|
27
28
|
module JenkinsLauncher
|
@@ -42,6 +43,21 @@ module JenkinsLauncher
|
|
42
43
|
@config = ConfigLoader.new
|
43
44
|
end
|
44
45
|
|
46
|
+
no_tasks do
|
47
|
+
def print_status(status)
|
48
|
+
case status
|
49
|
+
when "success"
|
50
|
+
puts "Build status: #{status.upcase}".green
|
51
|
+
when "failure"
|
52
|
+
puts "Build status: #{status.upcase}".red
|
53
|
+
when "unstable"
|
54
|
+
puts "Build status: #{status.upcase}".yellow
|
55
|
+
else
|
56
|
+
puts "Build status: #{status.upcase}"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
45
61
|
desc "version", "Shows current version"
|
46
62
|
def version
|
47
63
|
puts JenkinsLauncher::VERSION
|
@@ -53,7 +69,7 @@ module JenkinsLauncher
|
|
53
69
|
unless @api.job_exists?(params[:name])
|
54
70
|
@api.create_job(params)
|
55
71
|
else
|
56
|
-
puts "The job is already created. Please use 'start' command to build the job."
|
72
|
+
puts "The job is already created. Please use 'start' command to build the job.".yellow
|
57
73
|
end
|
58
74
|
end
|
59
75
|
|
@@ -70,10 +86,10 @@ module JenkinsLauncher
|
|
70
86
|
sleep quiet_period
|
71
87
|
refresh_rate = options[:refresh_rate] ? options[:refresh_rate].to_i : 5
|
72
88
|
@api.display_progressive_console_output(params[:name], refresh_rate)
|
73
|
-
|
89
|
+
print_status(@api.get_job_status(params[:name]))
|
74
90
|
@api.delete_job(params[:name]) if options[:delete_after]
|
75
91
|
else
|
76
|
-
puts "Build is already running. Run 'attach' command to attach to existing build and watch progress."
|
92
|
+
puts "Build is already running. Run 'attach' command to attach to existing build and watch progress.".yellow
|
77
93
|
end
|
78
94
|
end
|
79
95
|
|
@@ -81,9 +97,9 @@ module JenkinsLauncher
|
|
81
97
|
def stop(config_file)
|
82
98
|
params = @config.load_config(config_file)
|
83
99
|
if !@api.job_exists?(params[:name])
|
84
|
-
puts "The job doesn't exist"
|
100
|
+
puts "The job doesn't exist".red
|
85
101
|
elsif !@api.job_building?(params[:name])
|
86
|
-
puts "The job is currently not building or it may have finished already."
|
102
|
+
puts "The job is currently not building or it may have finished already.".yellow
|
87
103
|
else
|
88
104
|
@api.stop_job(params[:name])
|
89
105
|
end
|
@@ -95,29 +111,41 @@ module JenkinsLauncher
|
|
95
111
|
def attach(config_file)
|
96
112
|
params = @config.load_config(config_file)
|
97
113
|
if !@api.job_exists?(params[:name])
|
98
|
-
puts "Job is not created. Please use the 'start' command to create and build the job."
|
114
|
+
puts "Job is not created. Please use the 'start' command to create and build the job.".red
|
99
115
|
elsif !@api.job_building?(params[:name])
|
100
|
-
puts "Job is not running. Please use the 'start' command to build the job."
|
116
|
+
puts "Job is not running. Please use the 'start' command to build the job.".yellow
|
101
117
|
else
|
102
118
|
refresh_rate = options[:refresh_rate] ? options[:refresh_rate].to_i : 5
|
103
119
|
@api.display_progressive_console_output(params[:name], refresh_rate)
|
104
|
-
|
120
|
+
print_status(@api.get_job_status(params[:name]))
|
105
121
|
@api.delete_job(params[:name]) if options[:delete_after]
|
106
122
|
end
|
107
123
|
end
|
108
124
|
|
125
|
+
desc "console CONFIG", "Show the console output of the recent build if any"
|
126
|
+
def console(config_file)
|
127
|
+
params = @config.load_config(config_file)
|
128
|
+
if !@api.job_exists?(params[:name])
|
129
|
+
puts "Job is not created. Please use the 'create' or 'start' command to create or/and build the job.".red
|
130
|
+
elsif @api.job_building?(params[:name])
|
131
|
+
puts "The job is currently building. Please use the 'attach' command to attach to the running build and watch progress".yellow
|
132
|
+
else
|
133
|
+
@api.display_progressive_console_output(params[:name], 5)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
109
137
|
desc "destroy CONFIG", "Destroy the job from Jenkins server"
|
110
138
|
method_option :force, :type => :boolean, :aliases => "-f", :desc => "Stop the job if it is already running"
|
111
139
|
def destroy(config_file)
|
112
140
|
params = @config.load_config(config_file)
|
113
141
|
if !@api.job_exists?(params[:name])
|
114
|
-
puts "The job doesn't exist or already destroyed."
|
142
|
+
puts "The job doesn't exist or already destroyed.".yellow
|
115
143
|
elsif @api.job_building?(params[:name]) && !options[:force]
|
116
144
|
msg = ''
|
117
145
|
msg << "The job is currently building. Please use the 'stop' command or wait until the build is completed."
|
118
146
|
msg << " The --force option can be used to stop the build and destroy immediately."
|
119
147
|
msg << " If you would like to watch the progress, use the 'attach' command."
|
120
|
-
puts msg
|
148
|
+
puts msg.yellow
|
121
149
|
else
|
122
150
|
@api.stop_job(params[:name]) if options[:force] && @api.job_building?(params[:name])
|
123
151
|
@api.delete_job(params[:name])
|
@@ -35,11 +35,25 @@ module JenkinsLauncher
|
|
35
35
|
|
36
36
|
def validate_config(loaded_params)
|
37
37
|
valid_params = {}
|
38
|
+
# Name
|
38
39
|
raise "'name' is required and not set in the yml file." unless loaded_params['name']
|
39
40
|
valid_params[:name] = loaded_params['name']
|
40
|
-
|
41
|
+
|
42
|
+
# Source control
|
43
|
+
# Git, Subversion
|
44
|
+
if loaded_params['git']
|
45
|
+
valid_params[:scm_provider] = 'git'
|
46
|
+
valid_params[:scm_url] = loaded_params['git']
|
47
|
+
valid_params[:scm_branch] = loaded_params['ref'] ? loaded_params['ref'] : 'master'
|
48
|
+
elsif loaded_params['svn']
|
49
|
+
valid_params[:scm_provider] = 'subversion'
|
50
|
+
valid_params[:scm_url] = loaded_params['svn']
|
51
|
+
end
|
52
|
+
|
53
|
+
# Shell command
|
54
|
+
if loaded_params['script']
|
41
55
|
valid_params[:shell_command] = ''
|
42
|
-
loaded_params['
|
56
|
+
loaded_params['script'].each do |command|
|
43
57
|
valid_params[:shell_command] << command + "\n"
|
44
58
|
end
|
45
59
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2013 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
|
+
class String
|
24
|
+
colors = %w[black red green yellow blue magenta cyan white]
|
25
|
+
colors.concat colors.map { |c| "light#{c}" }
|
26
|
+
colors.each_with_index do |color, i|
|
27
|
+
define_method(color) { "\e[38;5;#{i}m#{self}\e[0m" }
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2013 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('../core_ext/string', __FILE__)
|
data/lib/jenkins_launcher.rb
CHANGED
@@ -24,3 +24,4 @@ require File.expand_path('../jenkins_launcher/config_loader', __FILE__)
|
|
24
24
|
require File.expand_path('../jenkins_launcher/api_interface', __FILE__)
|
25
25
|
require File.expand_path('../jenkins_launcher/cli', __FILE__)
|
26
26
|
require File.expand_path('../jenkins_launcher/version', __FILE__)
|
27
|
+
require File.expand_path('../jenkins_launcher/core_ext', __FILE__)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jenkins_launcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -158,11 +158,15 @@ files:
|
|
158
158
|
- README.md
|
159
159
|
- Rakefile
|
160
160
|
- bin/jlaunch
|
161
|
+
- config/sample-git.yml
|
162
|
+
- config/sample-svn.yml
|
161
163
|
- config/sample.yml
|
162
164
|
- lib/jenkins_launcher.rb
|
163
165
|
- lib/jenkins_launcher/api_interface.rb
|
164
166
|
- lib/jenkins_launcher/cli.rb
|
165
167
|
- lib/jenkins_launcher/config_loader.rb
|
168
|
+
- lib/jenkins_launcher/core_ext.rb
|
169
|
+
- lib/jenkins_launcher/core_ext/string.rb
|
166
170
|
- lib/jenkins_launcher/version.rb
|
167
171
|
homepage: https://github.com/arangamani/jenkins_launcher
|
168
172
|
licenses: []
|