capistrano-strategy-jenkins_artifact 0.1.1 → 0.2.0

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: 1666d310444ef061c387edb1d9a231242c0da5f7
4
- data.tar.gz: 6f2148ddc3011d63230ebcbb1e9606deec81a341
3
+ metadata.gz: de8c96f8b6ac33c572302110649f7f28e085388e
4
+ data.tar.gz: c5b909e7c364ee9d6ebfbcd556fb5222b7a2203c
5
5
  SHA512:
6
- metadata.gz: 978b52fe45eb6f924f132439391ac7f2fa013c961b6b0c3c86d8ec19099e7d54d165205691a8bdfdc688dcdfe3cdb4d215e9ea44b3fbc3e698f513f6c1ed494c
7
- data.tar.gz: 46f331f96c5ccfef9f0ffa0a31905409850e58e5ac41cc601382b79b35dec945afbe1d6b6cc7fc97fba61e45f2ebdf902618e863a48e14a78c9bd1c50d7a8187
6
+ metadata.gz: cec6f8ee6002b11712cd81a021f66a18269354fba78d998bcce3315a0d25124825aca547106f0017e1927306f2c42e3f25a2ff3b5dc39095dbdd4739eebdc72d
7
+ data.tar.gz: c6a77f098ed3f8c0e005c423aedbd8e35f02f1caed67f114333c291ed503d6fbbbf0a75b46a2c7dd7c3a9162f029272a072e4c4d5882bed945a347f301f17b3e
data/README.md CHANGED
@@ -22,7 +22,19 @@ Or install it yourself as:
22
22
 
23
23
  In your `Capfile` (`config/deploy.rb`, or `config/deploy/**/*.rb`):
24
24
 
25
+ ### General job
26
+
27
+ ```ruby
28
+ set :jenkins_origin, URI.parse('http://ci.example.com')
29
+ set :build_project, 'build-artifact-job'
30
+ set :deploy_via, :jenkins_artifact
31
+ ```
32
+
33
+ ### Multibranch job
34
+
25
35
  ```ruby
36
+ set :jenkins_origin, URI.parse('http://ci.example.com/job/multibranch-job')
37
+ set :is_multibranch_job, true
26
38
  set :deploy_via, :jenkins_artifact
27
39
  ```
28
40
 
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  Gem::Specification.new do |spec|
3
3
  spec.name = "capistrano-strategy-jenkins_artifact"
4
- spec.version = "0.1.1"
4
+ spec.version = "0.2.0"
5
5
  spec.authors = ["aereal"]
6
6
  spec.email = ["aereal@aereal.org"]
7
7
 
@@ -25,16 +25,18 @@ end
25
25
 
26
26
  class ::Capistrano::Deploy::Strategy::JenkinsArtifact < ::Capistrano::Deploy::Strategy::Base
27
27
  def deploy!
28
+ dir_name = exists?(:is_multibranch_job) && fetch(:is_multibranch_job) ? fetch(:branch) : fetch(:build_project)
29
+
28
30
  jenkins_origin = fetch(:jenkins_origin) or abort ":jenkins_origin configuration must be defined"
29
31
  client = JenkinsApi::Client.new(server_url: jenkins_origin.to_s)
30
32
  set(:artifact_url) do
31
33
  uri = ''
32
34
  if exists?(:artifact_relative_path)
33
- uri = client.job.find_artifact_with_path(fetch(:build_project), fetch(:artifact_relative_path))
35
+ uri = client.job.find_artifact_with_path(dir_name, fetch(:artifact_relative_path))
34
36
  else
35
- uri = client.job.find_artifact(fetch(:build_project))
37
+ uri = client.job.find_artifact(dir_name)
36
38
  end
37
- abort "No artifact found for #{fetch(:build_project)}" if uri.empty?
39
+ abort "No artifact found for #{dir_name}" if uri.empty?
38
40
  URI.parse(uri).tap {|uri|
39
41
  uri.scheme = jenkins_origin.scheme
40
42
  uri.host = jenkins_origin.host
@@ -42,8 +44,8 @@ class ::Capistrano::Deploy::Strategy::JenkinsArtifact < ::Capistrano::Deploy::St
42
44
  }.to_s
43
45
  end
44
46
 
45
- build_num = client.job.get_last_successful_build_number(fetch(:build_project), "origin/#{fetch(:branch)}")
46
- timestamp = client.job.get_build_details(fetch(:build_project), build_num)['timestamp']
47
+ build_num = client.job.get_last_successful_build_number(dir_name, "origin/#{fetch(:branch)}")
48
+ timestamp = client.job.get_build_details(dir_name, build_num)['timestamp']
47
49
  deploy_at = Time.at(timestamp / 1000)
48
50
 
49
51
  set(:release_name, deploy_at.strftime('%Y%m%d%H%M%S'))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-strategy-jenkins_artifact
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - aereal
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-27 00:00:00.000000000 Z
11
+ date: 2016-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jenkins_api_client