cartage 1.0 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Cartage.yml.rdoc +17 -5
- data/History.rdoc +18 -0
- data/cartage.yml.sample +17 -6
- data/lib/cartage.rb +41 -13
- 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: 76442e63f895e68ab77395c7070db5a050609eaa
|
4
|
+
data.tar.gz: 90a158c13769878cf94f637d2c3757008e7e54ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd325df936363b4df3016284b183af381f0a3ca7af67fdb84df0a6611803b90f21cddc2a324dc5a46ac48e42364c5b748ad3931f56d6804725011462a5e84770
|
7
|
+
data.tar.gz: 6d454884b43b7d55a4f0e5141ab26d15f98b442963045cdb2691fbb5baadb8b7d2555e0db006b59a40ad33d158eb5ad8fdbc39aa0efa816ae51f56c6e16ec521
|
data/Cartage.yml.rdoc
CHANGED
@@ -258,14 +258,26 @@ as cartage-remote runs SSH in a paranoid mode.
|
|
258
258
|
The postbuild script that will be run on the local system. This is optional
|
259
259
|
with no default (no post-build actions).
|
260
260
|
|
261
|
+
The postbuild script will be passed the stage identifier as <tt>$1</tt>
|
262
|
+
(valid values are +config+, +ssh_config+, +prebuild+, +remote_clone+,
|
263
|
+
+remote_build+, +cleanup+, or +finished+). If the build was interrupted with
|
264
|
+
an error, the error message will be passed as <tt>$2</tt>.
|
265
|
+
|
261
266
|
An example that posts a message to Slack is below.
|
262
267
|
|
263
268
|
plugins:
|
264
269
|
remote:
|
265
270
|
postbuild: |
|
266
271
|
#!/bin/bash
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
+
case ${1:-undefined} in
|
273
|
+
finished)
|
274
|
+
t="token=SLACK_TOKEN"
|
275
|
+
c="channel=%23ci"
|
276
|
+
d=MYDOMAIN
|
277
|
+
u="https://${d}.slack.com/services/hooks/slackbot?${t}&${c}"
|
278
|
+
curl --data "Build %<name>s-%<timestamp>s complete." ${u}
|
279
|
+
;;
|
280
|
+
*)
|
281
|
+
: # ${1} is the stage, ${2} is the error message
|
282
|
+
;;
|
283
|
+
esac
|
data/History.rdoc
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
=== 1.1 / 2015-03-26
|
2
|
+
|
3
|
+
* 1 major enhancement
|
4
|
+
|
5
|
+
* Added a Cartage::StatusError with an exitstatus support.
|
6
|
+
Cartage::QuietError is now based on this.
|
7
|
+
|
8
|
+
* 1 minor bugfix
|
9
|
+
|
10
|
+
* Restored an accidentally removed method,
|
11
|
+
Cartage::#create_bundle_cache.
|
12
|
+
|
13
|
+
* 2 documentation improvements
|
14
|
+
|
15
|
+
* Identified postbuild script stages.
|
16
|
+
|
17
|
+
* Improved the Slack notifier example postbuild script.
|
18
|
+
|
1
19
|
=== 1.0 / 2015-03-24
|
2
20
|
|
3
21
|
* 1 major enhancement
|
data/cartage.yml.sample
CHANGED
@@ -153,14 +153,26 @@ plugins:
|
|
153
153
|
|
154
154
|
# The postbuild script that will be run on the local system. This is
|
155
155
|
# optional with no default (no post-build actions).
|
156
|
+
#
|
157
|
+
# This script will be passed the stage identifier as $1 (valid values are
|
158
|
+
# config, ssh_config, prebuild, remote_clone, remote_build, cleanup, or
|
159
|
+
# finished). If the build was interrupted with an error, the error
|
160
|
+
# message will be passed as $2.
|
156
161
|
# ---
|
157
162
|
# postbuild: |
|
158
163
|
# #!/bin/bash
|
159
|
-
#
|
160
|
-
#
|
161
|
-
#
|
162
|
-
#
|
163
|
-
#
|
164
|
+
# case ${1:-undefined} in
|
165
|
+
# finished)
|
166
|
+
# t="token=SLACK_TOKEN"
|
167
|
+
# c="channel=%23ci"
|
168
|
+
# d=MYDOMAIN
|
169
|
+
# u="https://${d}.slack.com/services/hooks/slackbot?${t}&${c}"
|
170
|
+
# curl --data "Build %<name>s-%<timestamp>s complete." ${u}
|
171
|
+
# ;;
|
172
|
+
# *)
|
173
|
+
# : # ${1} is the stage, ${2} is the error message
|
174
|
+
# ;;
|
175
|
+
# esac
|
164
176
|
|
165
177
|
# This must not be indented for it to work.
|
166
178
|
<% if File.exist?('config/ansible/cartage.yml') %>
|
@@ -169,4 +181,3 @@ plugins:
|
|
169
181
|
<% if File.exist?('config/local/cartage.yml') %>
|
170
182
|
<%= File.read('config/local/cartage.yml') %>
|
171
183
|
<% end %>
|
172
|
-
|
data/lib/cartage.rb
CHANGED
@@ -2,17 +2,29 @@ require 'pathname'
|
|
2
2
|
|
3
3
|
# Cartage, a package builder.
|
4
4
|
class Cartage
|
5
|
-
VERSION = '1.
|
5
|
+
VERSION = '1.1' #:nodoc:
|
6
|
+
|
7
|
+
# Plug-in commands that want to return a specific exit code should use
|
8
|
+
# Cartage::StatusError to wrap the error.
|
9
|
+
class StatusError < StandardError
|
10
|
+
# Initialize the exception with +exitstatus+ and the exception to wrap.
|
11
|
+
def initialize(exitstatus, exception_or_message)
|
12
|
+
super(exception_or_message) if exception_or_message
|
13
|
+
@exitstatus = exitstatus
|
14
|
+
end
|
6
15
|
|
7
|
-
|
8
|
-
|
9
|
-
|
16
|
+
# The exit status to be returned from this exception.
|
17
|
+
attr_reader :exitstatus
|
18
|
+
end
|
19
|
+
|
20
|
+
# Plug-in commands that want to return a non-zero exit code without a message
|
21
|
+
# should raise Cartage::QuietError.new(exitstatus).
|
22
|
+
class QuietError < StatusError
|
10
23
|
# Initialize the exception with +exitstatus+.
|
11
24
|
def initialize(exitstatus)
|
12
|
-
|
25
|
+
super(exitstatus, nil)
|
13
26
|
end
|
14
27
|
|
15
|
-
# The exit status to be returned from this exception.
|
16
28
|
attr_reader :exitstatus
|
17
29
|
end
|
18
30
|
|
@@ -285,6 +297,10 @@ class Cartage
|
|
285
297
|
run %W(tar xfj #{bundle_cache} -C #{work_path}) if bundle_cache.exist?
|
286
298
|
end
|
287
299
|
|
300
|
+
def create_bundle_cache
|
301
|
+
run %W(tar cfj #{bundle_cache} -C #{work_path} vendor/bundle)
|
302
|
+
end
|
303
|
+
|
288
304
|
def install_vendor_bundle
|
289
305
|
extract_bundle_cache
|
290
306
|
|
@@ -449,13 +465,10 @@ configuration file.
|
|
449
465
|
|
450
466
|
registered_commands.uniq.each { |cmd| cli.add_command(cmd.new(cartage)) }
|
451
467
|
cli.parse
|
452
|
-
0
|
453
|
-
rescue
|
454
|
-
|
455
|
-
|
456
|
-
$stderr.puts "Error:\n " + e.message
|
457
|
-
$stderr.puts e.backtrace.join("\n") if cartage.verbose
|
458
|
-
2
|
468
|
+
return 0
|
469
|
+
rescue Exception => exception
|
470
|
+
show_message_for exception, for_cartage: cartage
|
471
|
+
return exitstatus_for(exception)
|
459
472
|
end
|
460
473
|
|
461
474
|
# Set options common to anything that builds a package (that is, it calls
|
@@ -491,6 +504,21 @@ configuration file.
|
|
491
504
|
def registered_commands
|
492
505
|
@registered_commands ||= []
|
493
506
|
end
|
507
|
+
|
508
|
+
def exitstatus_for(exception)
|
509
|
+
if exception.respond_to? :exitstatus
|
510
|
+
exception.exitstatus
|
511
|
+
else
|
512
|
+
2
|
513
|
+
end
|
514
|
+
end
|
515
|
+
|
516
|
+
def show_message_for(exception, for_cartage:)
|
517
|
+
unless exception.kind_of?(Cartage::QuietError)
|
518
|
+
$stderr.puts "Error:\n " + exception.message
|
519
|
+
$stderr.puts exception.backtrace.join("\n") if for_cartage.verbose
|
520
|
+
end
|
521
|
+
end
|
494
522
|
end
|
495
523
|
|
496
524
|
require_relative 'cartage/config'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cartage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Austin Ziegler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cmdparse
|