cartage 1.0 → 1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d1f67642374f3f5997dd5d735d20b33e8e035c5c
4
- data.tar.gz: 64cd9abc15c2bf0a2e8097545a1013d434b38e6b
3
+ metadata.gz: 76442e63f895e68ab77395c7070db5a050609eaa
4
+ data.tar.gz: 90a158c13769878cf94f637d2c3757008e7e54ba
5
5
  SHA512:
6
- metadata.gz: 5939952a64d810668aeec416727bdaadda5011d594115719bbfd5aaf3af3ee86d89614dd3689d7cfc30c41a76b459e7de1a40c811f13285c5eb56b8e101d1d42
7
- data.tar.gz: dfd005d425fff150f5b465c1a88af03f6e2df935a3c2152f0607e84265524d44a6ef90d8dcb3c59b28e0463d2ded90ae9ece49a58dcf87803fe91e87b8e9b4d3
6
+ metadata.gz: bd325df936363b4df3016284b183af381f0a3ca7af67fdb84df0a6611803b90f21cddc2a324dc5a46ac48e42364c5b748ad3931f56d6804725011462a5e84770
7
+ data.tar.gz: 6d454884b43b7d55a4f0e5141ab26d15f98b442963045cdb2691fbb5baadb8b7d2555e0db006b59a40ad33d158eb5ad8fdbc39aa0efa816ae51f56c6e16ec521
@@ -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
- t="token=SLACK_TOKEN"
268
- c="channel=%23ci"
269
- d=MYDOMAIN
270
- u="https://${d}.slack.com/services/hooks/slackbot?${t}&${c}"
271
- curl --data "Build %<name>s-%<timestamp>s complete." ${u}
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
@@ -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
@@ -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
- # t="token=SLACK_TOKEN"
160
- # c="channel=%23ci"
161
- # d=MYDOMAIN
162
- # u="https://${d}.slack.com/services/hooks/slackbot?${t}&${c}"
163
- # curl --data "Build %<name>s-%<timestamp>s complete." ${u}
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
-
@@ -2,17 +2,29 @@ require 'pathname'
2
2
 
3
3
  # Cartage, a package builder.
4
4
  class Cartage
5
- VERSION = '1.0' #:nodoc:
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
- # Plug-in commands that want to return a non-zero exit code should raise
8
- # Cartage::QuietError.new(exitstatus).
9
- class QuietError < StandardError
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
- @exitstatus = exitstatus
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 Cartage::QuietError => qe
454
- qe.exitstatus
455
- rescue StandardError => e
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.0'
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-24 00:00:00.000000000 Z
11
+ date: 2015-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cmdparse