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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de8c96f8b6ac33c572302110649f7f28e085388e
|
4
|
+
data.tar.gz: c5b909e7c364ee9d6ebfbcd556fb5222b7a2203c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
@@ -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(
|
35
|
+
uri = client.job.find_artifact_with_path(dir_name, fetch(:artifact_relative_path))
|
34
36
|
else
|
35
|
-
uri = client.job.find_artifact(
|
37
|
+
uri = client.job.find_artifact(dir_name)
|
36
38
|
end
|
37
|
-
abort "No artifact found for #{
|
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(
|
46
|
-
timestamp = client.job.get_build_details(
|
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.
|
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-
|
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
|