pushwagner 0.0.1 → 0.0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.md +1 -0
- data/TODO.md +33 -0
- data/lib/pushwagner/environment.rb +2 -2
- data/lib/pushwagner/main.rb +3 -3
- data/lib/pushwagner/maven.rb +15 -10
- data/lib/pushwagner/version.rb +2 -2
- data/spec/maven_spec.rb +10 -9
- metadata +4 -2
data/.gitignore
CHANGED
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
[X] Release early, [ ] Release often
|
data/TODO.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
Static-file provision:
|
2
|
+
|
3
|
+
[ ] Support hooks, i.e.:
|
4
|
+
hooks:
|
5
|
+
before:
|
6
|
+
- cmd: mvn package
|
7
|
+
cwd: anyone-web
|
8
|
+
scope: local
|
9
|
+
after:
|
10
|
+
- cmd: unzip anyone-web.zip
|
11
|
+
cwd: /srv/www/gethubble.com
|
12
|
+
scope: remote
|
13
|
+
[ ] Add another wrapper for files:
|
14
|
+
static:
|
15
|
+
name:
|
16
|
+
files: # files to upload
|
17
|
+
- ...
|
18
|
+
hooks: # before and after deploy hooks
|
19
|
+
- ...
|
20
|
+
services: # assumes service with same name
|
21
|
+
- restart
|
22
|
+
|
23
|
+
|
24
|
+
Maven:
|
25
|
+
[ ] Support hooks (?)
|
26
|
+
|
27
|
+
Conventions:
|
28
|
+
- Maven artifacts are deployed to `$path_prefix/$artifact_id`
|
29
|
+
- Services assume name: `$artifact_id`
|
30
|
+
|
31
|
+
Static-files:
|
32
|
+
- Are uploaded to `$path_prefix/$name`
|
33
|
+
- Services assume name: `$name`
|
@@ -11,7 +11,7 @@ module Pushwagner
|
|
11
11
|
opts = HashWithIndifferentAccess.new(opts)
|
12
12
|
|
13
13
|
config_file = opts[:config_file] || File.join(File.dirname(__FILE__), '/config/deploy.yml')
|
14
|
-
@version = opts[:version]
|
14
|
+
@version = opts[:version].to_s
|
15
15
|
@current = opts[:environment] || 'development'
|
16
16
|
|
17
17
|
@config = HashWithIndifferentAccess.new(YAML::load_file(config_file) || {})
|
@@ -22,7 +22,7 @@ module Pushwagner
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def maven
|
25
|
-
@maven = config['maven'] ? Maven.new(config['maven'], version) : {}
|
25
|
+
@maven = (config['maven'] ? Maven.new(config['maven'], version) : {})
|
26
26
|
end
|
27
27
|
|
28
28
|
def maven?
|
data/lib/pushwagner/main.rb
CHANGED
@@ -10,12 +10,12 @@ module Pushwagner
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def set_version(version)
|
13
|
-
@environment.version = version
|
13
|
+
@environment.version = version.to_s
|
14
14
|
end
|
15
15
|
|
16
16
|
def deploy(opts = {})
|
17
|
-
Maven::Deployer.new(@environment, opts).deploy
|
18
|
-
Static::Deployer.new(@environment, opts).deploy
|
17
|
+
Maven::Deployer.new(@environment, opts).deploy if @environment.maven?
|
18
|
+
Static::Deployer.new(@environment, opts).deploy if @environment.static?
|
19
19
|
end
|
20
20
|
|
21
21
|
def restart(opts = {})
|
data/lib/pushwagner/maven.rb
CHANGED
@@ -9,16 +9,22 @@ module Pushwagner
|
|
9
9
|
|
10
10
|
attr_reader :repository, :artifacts
|
11
11
|
def initialize(maven, version)
|
12
|
-
|
12
|
+
required("Need maven configuration") unless maven
|
13
13
|
|
14
|
-
@version = version || required("Deployment version for artifacts is required")
|
14
|
+
@version = version.to_s || required("Deployment version for artifacts is required")
|
15
15
|
@repository = Repository.new(maven['repositories'])
|
16
|
-
@artifacts = Hash[(maven['artifacts'] ||
|
16
|
+
@artifacts = Hash[(maven['artifacts'] || required("Requires at least one maven artifact")).map { |k,h| [k, Artifact.new(h['artifact_id'], h['group_id'], h['version'] || version)] }]
|
17
|
+
|
18
|
+
(artifacts && repository) || required("Could not initialize maven configuration")
|
17
19
|
end
|
18
20
|
|
19
21
|
def required(msg)
|
20
22
|
raise StandardError.new(msg)
|
21
23
|
end
|
24
|
+
|
25
|
+
def any?
|
26
|
+
artifacts && repository
|
27
|
+
end
|
22
28
|
end
|
23
29
|
|
24
30
|
class Maven::Artifact
|
@@ -63,7 +69,7 @@ module Pushwagner
|
|
63
69
|
|
64
70
|
def absolute_url(artifact)
|
65
71
|
if artifact.snapshot?
|
66
|
-
doc = Nokogiri::XML(open(URI.parse("#{snapshots_url}/#{artifact.base_path}/maven-metadata.xml"), :http_basic_authentication => authentication(
|
72
|
+
doc = Nokogiri::XML(open(URI.parse("#{snapshots_url}/#{artifact.base_path}/maven-metadata.xml"), :http_basic_authentication => authentication(true).split(":")))
|
67
73
|
snapshot_version = doc.xpath("//metadata/versioning/snapshotVersions/snapshotVersion/value/text()").first.content
|
68
74
|
return "#{snapshots_url}/#{artifact.base_path}/#{artifact.artifact_id}-#{snapshot_version}.jar"
|
69
75
|
end
|
@@ -118,22 +124,21 @@ module Pushwagner
|
|
118
124
|
def pull_artifact(name, artifact, host)
|
119
125
|
Net::SSH.start(host, environment.user) do |ssh|
|
120
126
|
puts "Pulling #{repository.absolute_url(artifact)} to #{host}:#{environment.path_prefix}/#{artifact.jar_name}..."
|
121
|
-
ssh.exec("curl --user '#{repository.authentication(artifact.snapshot?)}' #{repository.absolute_url(artifact)} > #{environment.path_prefix}/#{artifact.jar_name}")
|
127
|
+
ssh.exec("curl --user '#{repository.authentication(artifact.snapshot?)}' #{repository.absolute_url(artifact)} > #{environment.path_prefix}/#{name}/#{artifact.jar_name}")
|
122
128
|
end
|
123
129
|
end
|
124
130
|
|
125
131
|
def mark_previous(name, host)
|
126
|
-
Net::SSH.start(host, user) do |ssh|
|
132
|
+
Net::SSH.start(host, environment.user) do |ssh|
|
127
133
|
puts "Marking previous release on #{host}..."
|
128
|
-
ssh.exec("cp -P #{environment.path_prefix}/#{name}.jar #{environment.path_prefix}/#{name}.previous.jar")
|
134
|
+
ssh.exec("cp -P #{environment.path_prefix}/#{name}/#{name}.jar #{environment.path_prefix}/#{name}/#{name}.previous.jar")
|
129
135
|
end
|
130
136
|
end
|
131
137
|
|
132
138
|
def mark_new(name, artifact, host)
|
133
|
-
Net::SSH.start(host, user) do |ssh|
|
134
|
-
cwd = deploy_path(app_name)
|
139
|
+
Net::SSH.start(host, environment.user) do |ssh|
|
135
140
|
puts "Marking #{artifact.jar_name} as current on #{host}..."
|
136
|
-
ssh.exec("ln -sf #{environment.path_prefix}/#{artifact.jar_name} #{environment.path_prefix}/#{name}.jar")
|
141
|
+
ssh.exec("ln -sf #{environment.path_prefix}/#{name}/#{artifact.jar_name} #{environment.path_prefix}/#{name}/#{name}.jar")
|
137
142
|
end
|
138
143
|
end
|
139
144
|
|
data/lib/pushwagner/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Pushwagner
|
2
|
-
VERSION = "0.0.1"
|
3
|
-
end
|
2
|
+
VERSION = "0.0.1.1"
|
3
|
+
end
|
data/spec/maven_spec.rb
CHANGED
@@ -9,6 +9,14 @@ describe Pushwagner::Maven do
|
|
9
9
|
expect { Pushwagner::Maven.new(cfg, nil) }.to raise_error(StandardError, "Deployment version for artifacts is required")
|
10
10
|
end
|
11
11
|
|
12
|
+
it "requires valid configuration" do
|
13
|
+
expect{Pushwagner::Maven.new(nil, "1baz")}.to raise_error(StandardError, "Need maven configuration")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "requires valid repositories configuration" do
|
17
|
+
expect{Pushwagner::Maven.new({}, "1baz")}.to raise_error(StandardError, "repositories configuration required")
|
18
|
+
end
|
19
|
+
|
12
20
|
it "trickles the version down to artifacts" do
|
13
21
|
m = Pushwagner::Maven.new(cfg, "1foo")
|
14
22
|
expect(m.artifacts["some-api"].version).to eq("1foo")
|
@@ -19,17 +27,10 @@ describe Pushwagner::Maven do
|
|
19
27
|
expect(m.artifacts["some-notifier"].version).to eq("1.0final")
|
20
28
|
end
|
21
29
|
|
22
|
-
it "returns nil-object maven when not configured" do
|
23
|
-
m = Pushwagner::Maven.new({}, "1baz")
|
24
|
-
expect(m.artifacts).to be_nil
|
25
|
-
expect(m).to_not be_nil
|
26
|
-
end
|
27
|
-
|
28
30
|
describe "initialization of artifacts" do
|
29
|
-
it "
|
31
|
+
it "requires at least one artifact" do
|
30
32
|
cfg.delete('artifacts')
|
31
|
-
|
32
|
-
expect(m.artifacts.size).to eq(0)
|
33
|
+
expect {Pushwagner::Maven.new(cfg, "1bar")}.to raise_error(StandardError, "Requires at least one maven artifact")
|
33
34
|
end
|
34
35
|
it "parses two artifacts" do
|
35
36
|
m = Pushwagner::Maven.new(cfg, "1bar")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pushwagner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1
|
4
|
+
version: 0.0.1.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-11-
|
12
|
+
date: 2012-11-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: net-ssh
|
@@ -118,7 +118,9 @@ files:
|
|
118
118
|
- .rvmrc
|
119
119
|
- Gemfile
|
120
120
|
- Gemfile.lock
|
121
|
+
- README.md
|
121
122
|
- Rakefile
|
123
|
+
- TODO.md
|
122
124
|
- bin/pw
|
123
125
|
- lib/pushwagner.rb
|
124
126
|
- lib/pushwagner/environment.rb
|