capistrano-scm-jenkins 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,12 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capistrano-scm-jenkins (0.0.2)
4
+ capistrano-scm-jenkins (0.0.3)
5
5
  capistrano
6
+ net-netrc
6
7
 
7
8
  GEM
8
9
  remote: http://rubygems.org/
9
10
  specs:
11
+ Platform (0.4.0)
10
12
  capistrano (2.9.0)
11
13
  highline
12
14
  net-scp (>= 1.0.0)
@@ -15,6 +17,8 @@ GEM
15
17
  net-ssh-gateway (>= 1.1.0)
16
18
  diff-lcs (1.1.3)
17
19
  highline (1.6.8)
20
+ net-netrc (0.2.2)
21
+ Platform (>= 0.3.0)
18
22
  net-scp (1.0.4)
19
23
  net-ssh (>= 1.99.1)
20
24
  net-sftp (2.0.5)
data/NEWS.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.0.3 (2011-12-13)
2
+
3
+ * support netrc
4
+
1
5
  ## 0.0.2 (2011-11-26)
2
6
 
3
7
  * honor :scm_username and :scm_password
data/README.md CHANGED
@@ -19,11 +19,17 @@ a sample config/deploy.rb
19
19
  set :scm, :jenkins
20
20
 
21
21
  # uncomment following line if you want deploy unstable version
22
- # set :jenkins_use_unstable, true
22
+ # set :jenkins_use_unstable, true
23
23
 
24
24
  # jenkins username and password
25
- # set :scm_username, ENV['JENKINS_USERNAME']
26
- # set :scm_password, ENV['JENKINS_PASSWORD']
25
+ # set :scm_username, ENV['JENKINS_USERNAME']
26
+ # set :scm_password, ENV['JENKINS_PASSWORD']
27
+ # or use the netrc support for curl
28
+ # set :jenkins_use_netrc, true
29
+ #
30
+ # if you use netrc, add the following line in your $HOME/.netrc
31
+ # machine jenkins.example.com login USERNAME password secret
32
+
27
33
 
28
34
  set :user, 'lidaobing'
29
35
  set :use_sudo, false
@@ -23,5 +23,6 @@ deploy your build artifact with capistrano.
23
23
 
24
24
  # specify any dependencies here; for example:
25
25
  s.add_runtime_dependency "capistrano"
26
+ s.add_runtime_dependency "net-netrc"
26
27
  s.add_development_dependency "rspec"
27
28
  end
@@ -1,7 +1,7 @@
1
1
  module Capistrano
2
2
  module Scm
3
3
  module Jenkins
4
- VERSION = "0.0.2"
4
+ VERSION = "0.0.3"
5
5
  end
6
6
  end
7
7
  end
@@ -3,6 +3,7 @@ require 'tmpdir'
3
3
  require 'rexml/document'
4
4
 
5
5
  require 'capistrano/recipes/deploy/scm/base'
6
+ require 'net/netrc'
6
7
 
7
8
  module Capistrano
8
9
  module Deploy
@@ -43,7 +44,9 @@ module Capistrano
43
44
  private
44
45
 
45
46
  def authentication
46
- if variable(:scm_username) and variable(:scm_password)
47
+ if variable(:jenkins_use_netrc)
48
+ "--netrc"
49
+ elsif variable(:scm_username) and variable(:scm_password)
47
50
  "--user '#{variable(:scm_username)}:#{variable(:scm_password)}'"
48
51
  else
49
52
  ""
@@ -126,8 +129,8 @@ module Capistrano
126
129
  end
127
130
 
128
131
  def auth_opts
129
- if variable(:scm_username) and variable(:scm_username)
130
- {:http_basic_authentication => [variable(:scm_username), variable(:scm_password)]}
132
+ if jenkins_username and jenkins_password
133
+ {:http_basic_authentication => [jenkins_username, jenkins_password]}
131
134
  else
132
135
  {}
133
136
  end
@@ -136,6 +139,38 @@ module Capistrano
136
139
  def artifact_zip_url(revision)
137
140
  "#{repository}/#{revision}/artifact/*zip*/archive.zip"
138
141
  end
142
+
143
+ def jenkins_username
144
+ @jenkins_username ||= begin
145
+ if variable(:jenkins_use_netrc)
146
+ rc = Net::Netrc.locate(jenkins_hostname)
147
+ raise ".netrc missing or no entry found" if rc.nil?
148
+ rc.login
149
+ elsif variable(:scm_username)
150
+ variable(:scm_username)
151
+ else
152
+ nil
153
+ end
154
+ end
155
+ end
156
+
157
+ def jenkins_password
158
+ @jenkins_password ||= begin
159
+ if variable(:jenkins_use_netrc)
160
+ rc = Net::Netrc.locate(jenkins_hostname)
161
+ raise ".netrc missing or no entry found" if rc.nil?
162
+ rc.password
163
+ elsif variable(:scm_password)
164
+ variable(:scm_password)
165
+ else
166
+ nil
167
+ end
168
+ end
169
+ end
170
+
171
+ def jenkins_hostname
172
+ @jenkins_hostname ||= URI.parse(repository).host
173
+ end
139
174
  end
140
175
  end
141
176
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: capistrano-scm-jenkins
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - LI Daobing
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-11-26 00:00:00 +08:00
13
+ date: 2011-12-13 00:00:00 +08:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -25,7 +25,7 @@ dependencies:
25
25
  type: :runtime
26
26
  version_requirements: *id001
27
27
  - !ruby/object:Gem::Dependency
28
- name: rspec
28
+ name: net-netrc
29
29
  prerelease: false
30
30
  requirement: &id002 !ruby/object:Gem::Requirement
31
31
  none: false
@@ -33,8 +33,19 @@ dependencies:
33
33
  - - ">="
34
34
  - !ruby/object:Gem::Version
35
35
  version: "0"
36
- type: :development
36
+ type: :runtime
37
37
  version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: rspec
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ type: :development
48
+ version_requirements: *id003
38
49
  description: "\n\
39
50
  With this plugin, you can use jenkins build artifact as a repository, and\n\
40
51
  deploy your build artifact with capistrano.\n "