capistrano-scm-jenkins 0.0.5 → 0.0.6

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/.gitignore CHANGED
@@ -3,3 +3,4 @@
3
3
  pkg/*
4
4
  *.swp
5
5
  test
6
+ .idea
data/.travis.yml CHANGED
@@ -3,6 +3,7 @@ rvm:
3
3
  - 1.8.7
4
4
  - 1.9.2
5
5
  - 1.9.3
6
+ - 2.0.0
6
7
  - jruby-18mode
7
8
  - jruby-19mode
8
9
  - rbx-18mode
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in capistrano-scm-jenkins.gemspec
4
4
  gemspec
data/Gemfile.lock CHANGED
@@ -1,41 +1,41 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capistrano-scm-jenkins (0.0.5)
4
+ capistrano-scm-jenkins (0.0.6)
5
5
  capistrano
6
6
  net-netrc
7
7
  rubyzip
8
8
 
9
9
  GEM
10
- remote: http://rubygems.org/
10
+ remote: https://rubygems.org/
11
11
  specs:
12
12
  Platform (0.4.0)
13
- capistrano (2.14.1)
13
+ capistrano (2.14.2)
14
14
  highline
15
15
  net-scp (>= 1.0.0)
16
16
  net-sftp (>= 2.0.0)
17
17
  net-ssh (>= 2.0.14)
18
18
  net-ssh-gateway (>= 1.1.0)
19
- diff-lcs (1.1.3)
20
- highline (1.6.15)
19
+ diff-lcs (1.2.1)
20
+ highline (1.6.16)
21
21
  net-netrc (0.2.2)
22
22
  Platform (>= 0.3.0)
23
- net-scp (1.0.4)
24
- net-ssh (>= 1.99.1)
25
- net-sftp (2.0.5)
26
- net-ssh (>= 2.0.9)
27
- net-ssh (2.6.3)
28
- net-ssh-gateway (1.1.0)
29
- net-ssh (>= 1.99.1)
23
+ net-scp (1.1.0)
24
+ net-ssh (>= 2.6.5)
25
+ net-sftp (2.1.1)
26
+ net-ssh (>= 2.6.5)
27
+ net-ssh (2.6.6)
28
+ net-ssh-gateway (1.2.0)
29
+ net-ssh (>= 2.6.5)
30
30
  rake (10.0.3)
31
- rspec (2.12.0)
32
- rspec-core (~> 2.12.0)
33
- rspec-expectations (~> 2.12.0)
34
- rspec-mocks (~> 2.12.0)
35
- rspec-core (2.12.2)
36
- rspec-expectations (2.12.1)
37
- diff-lcs (~> 1.1.3)
38
- rspec-mocks (2.12.2)
31
+ rspec (2.13.0)
32
+ rspec-core (~> 2.13.0)
33
+ rspec-expectations (~> 2.13.0)
34
+ rspec-mocks (~> 2.13.0)
35
+ rspec-core (2.13.1)
36
+ rspec-expectations (2.13.0)
37
+ diff-lcs (>= 1.1.3, < 2.0)
38
+ rspec-mocks (2.13.0)
39
39
  rubyzip (0.9.9)
40
40
 
41
41
  PLATFORMS
data/NEWS.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.0.6 (2013-0319)
2
+
3
+ * [#1, #7] support https (thanks @lostintime)
4
+
1
5
  ## 0.0.5 (2013-01-31)
2
6
 
3
7
  * works under Windows (thanks @Iristyle)
data/README.md CHANGED
@@ -31,6 +31,12 @@ a sample config/deploy.rb
31
31
  #
32
32
  # if you use netrc, add the following line in your $HOME/.netrc
33
33
  # machine jenkins.example.com login USERNAME password secret
34
+ #
35
+ # bypass ssl verification
36
+ # set :jenkins_insecure, true
37
+ #
38
+ # deploy from artifact subfolder. (ex: mv zipout/#{:jenkins_artifact_path} #{destination})
39
+ # set :jenkins_artifact_path, 'archive'
34
40
 
35
41
 
36
42
  set :user, 'lidaobing'
@@ -1,7 +1,7 @@
1
1
  module Capistrano
2
2
  module Scm
3
3
  module Jenkins
4
- VERSION = "0.0.5"
4
+ VERSION = "0.0.6"
5
5
  end
6
6
  end
7
7
  end
@@ -18,46 +18,33 @@ module Capistrano
18
18
  end
19
19
 
20
20
  def query_revision(revision)
21
- return revision if revision =~ /^\d+$/
21
+ return revision if revision.to_s =~ /^\d+$/
22
22
  raise "invalid revision: #{revision}"
23
23
  end
24
24
 
25
25
  def checkout(revision, destination)
26
- download_url = artifact_zip_url(revision)
27
- Dir.mktmpdir { |dir|
28
- if variable(:jenkins_use_netrc)
29
- zip_path = File.expand_path(File.join(dir, 'archive.zip'))
30
- `curl #{authentication} -sO '#{download_url}'`
31
- if $?.exitstatus != 0
32
- raise "could not execute curl"
33
- end
34
- else
35
- options = {
36
- "User-Agent" => "capistrano-scm-jenkins@capistrano",
37
- "Referer" => "https://github.com/lidaobing/capistrano-scm-jenkins"
38
- }
39
- if variable(:scm_username) and variable(:scm_password)
40
- options[:http_basic_authentication] = [variable(:scm_username), variable(:scm_password)]
41
- end
42
-
43
- zip_path = open(download_url, options).path
44
- end
26
+ execute = []
45
27
 
46
- logger.info("Extracting #{zip_path} to #{destination}")
47
- Zip::ZipFile.open(zip_path) do |zipfile|
48
- zipfile.each { |e|
49
- fpath = File.join(destination, e.to_s)
50
- FileUtils.mkdir_p(File.dirname(fpath))
51
- # true to overwrite existing files
52
- zipfile.extract(e, fpath){ true }
53
- }
54
- end
55
- }
28
+ unless destination.end_with?('/')
29
+ destination = destination.to_s + '/'
30
+ end
31
+
32
+ execute << 'TMPDIR=`mktemp -d`'
33
+ execute << 'cd $TMPDIR'
34
+ execute << "curl #{curl_interface} #{insecure} #{authentication} -sO '#{artifact_zip_url(revision)}'"
35
+ if variable(:jenkins_artifact_path)
36
+ execute << 'unzip archive.zip -d \'out/\''
37
+ execute << "mv out/#{variable(:jenkins_artifact_path)} #{destination}"
38
+ else
39
+ execute << "unzip archive.zip -d \"#{destination}\""
56
40
 
57
- # HACK: rather than using shell commands to download / extract and
58
- # move files, use something cross platform, and fake a shell success
59
- # this does break the benchmarking of the system call, but oh well
60
- return 'true'
41
+ end
42
+ execute << 'rm -rf "$TMPDIR"'
43
+
44
+ execute.compact.join(' && ').gsub(/\s+/, ' ')
45
+ rescue ArgumentError => e
46
+ logger.log(Logger::IMPORTANT, e.message)
47
+ exit
61
48
  end
62
49
 
63
50
  alias_method :export, :checkout
@@ -85,6 +72,22 @@ module Capistrano
85
72
  end
86
73
  end
87
74
 
75
+ def insecure
76
+ if variable(:jenkins_insecure)
77
+ '--insecure'
78
+ else
79
+ ''
80
+ end
81
+ end
82
+
83
+ def curl_interface
84
+ if variable(:jenkins_curl_interface)
85
+ "--interface '#{variable(:jenkins_curl_interface)}'"
86
+ else
87
+ ''
88
+ end
89
+ end
90
+
88
91
  def use_unstable?
89
92
  !!variable(:jenkins_use_unstable)
90
93
  end
@@ -95,7 +98,7 @@ module Capistrano
95
98
  logger.info ''
96
99
  logger.info "BUILD LOG"
97
100
  logger.info '========='
98
- REXML::XPath.each(doc,"./entry") do |entry|
101
+ REXML::XPath.each(doc, "./entry") do |entry|
99
102
  title = REXML::XPath.first(entry, "./title").text
100
103
  time = REXML::XPath.first(entry, "./updated").text
101
104
  build_number = get_build_number_from_rss_all_title(title).to_i
@@ -110,7 +113,7 @@ module Capistrano
110
113
  doc = REXML::Document.new(message).root
111
114
  logger.info "SCM LOG"
112
115
  logger.info '======='
113
- REXML::XPath.each(doc,"./entry") do |entry|
116
+ REXML::XPath.each(doc, "./entry") do |entry|
114
117
  title = REXML::XPath.first(entry, "./title").text
115
118
  time = REXML::XPath.first(entry, "./updated").text
116
119
  content = REXML::XPath.first(entry, "./content").text
@@ -131,7 +134,7 @@ module Capistrano
131
134
  if use_unstable
132
135
  valid_end_strings << '(unstable)'
133
136
  end
134
- REXML::XPath.each(doc,"./entry/title") do |title|
137
+ REXML::XPath.each(doc, "./entry/title") do |title|
135
138
  title = title.text
136
139
  for x in valid_end_strings
137
140
  return get_build_number_from_rss_all_title(title) if title.end_with? x
@@ -150,14 +153,14 @@ module Capistrano
150
153
 
151
154
  def rss_all
152
155
  begin
153
- @rss_all ||= open(repository + '/rssAll', accept_language.merge(auth_opts)).read()
156
+ @rss_all ||= open(repository + '/rssAll', accept_language.merge(auth_opts).merge(ssl_opts)).read()
154
157
  rescue => e
155
158
  raise Capistrano::Error, "open url #{repository + '/rssAll'} failed: #{e}"
156
159
  end
157
160
  end
158
161
 
159
162
  def rss_changelog
160
- @rss_changelog ||= open(repository + '/rssChangelog', accept_language.merge(auth_opts)).read()
163
+ @rss_changelog ||= open(repository + '/rssChangelog', accept_language.merge(auth_opts).merge(ssl_opts)).read()
161
164
  end
162
165
 
163
166
  def accept_language
@@ -172,36 +175,44 @@ module Capistrano
172
175
  end
173
176
  end
174
177
 
178
+ def ssl_opts
179
+ if variable(:jenkins_insecure)
180
+ {:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE}
181
+ else
182
+ {}
183
+ end
184
+ end
185
+
175
186
  def artifact_zip_url(revision)
176
187
  "#{repository}/#{revision}/artifact/*zip*/archive.zip"
177
188
  end
178
189
 
179
190
  def jenkins_username
180
191
  @jenkins_username ||= begin
181
- if variable(:jenkins_use_netrc)
182
- rc = Net::Netrc.locate(jenkins_hostname)
183
- raise ".netrc missing or no entry found" if rc.nil?
184
- rc.login
185
- elsif variable(:scm_username)
186
- variable(:scm_username)
187
- else
188
- nil
189
- end
190
- end
192
+ if variable(:jenkins_use_netrc)
193
+ rc = Net::Netrc.locate(jenkins_hostname)
194
+ raise ".netrc missing or no entry found" if rc.nil?
195
+ rc.login
196
+ elsif variable(:scm_username)
197
+ variable(:scm_username)
198
+ else
199
+ nil
200
+ end
201
+ end
191
202
  end
192
203
 
193
204
  def jenkins_password
194
205
  @jenkins_password ||= begin
195
- if variable(:jenkins_use_netrc)
196
- rc = Net::Netrc.locate(jenkins_hostname)
197
- raise ".netrc missing or no entry found" if rc.nil?
198
- rc.password
199
- elsif variable(:scm_password)
200
- variable(:scm_password)
201
- else
202
- nil
203
- end
204
- end
206
+ if variable(:jenkins_use_netrc)
207
+ rc = Net::Netrc.locate(jenkins_hostname)
208
+ raise ".netrc missing or no entry found" if rc.nil?
209
+ rc.password
210
+ elsif variable(:scm_password)
211
+ variable(:scm_password)
212
+ else
213
+ nil
214
+ end
215
+ end
205
216
  end
206
217
 
207
218
  def jenkins_hostname
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-scm-jenkins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
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: 2013-02-03 00:00:00.000000000 Z
12
+ date: 2013-03-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano
@@ -127,7 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
127
127
  version: '0'
128
128
  segments:
129
129
  - 0
130
- hash: -2250672160818474877
130
+ hash: 1219470571275363423
131
131
  required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  none: false
133
133
  requirements:
@@ -136,10 +136,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  version: '0'
137
137
  segments:
138
138
  - 0
139
- hash: -2250672160818474877
139
+ hash: 1219470571275363423
140
140
  requirements: []
141
141
  rubyforge_project: capistrano-scm-jenkins
142
- rubygems_version: 1.8.24
142
+ rubygems_version: 1.8.25
143
143
  signing_key:
144
144
  specification_version: 3
145
145
  summary: use jenkins as a capistrano scm