capistrano-jira 0.2.0 → 0.3.1
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Changelog.md +3 -0
- data/README.md +7 -5
- data/capistrano-jira.gemspec +4 -4
- data/lib/capistrano/jira.rb +4 -0
- data/lib/capistrano/jira/commit.rb +12 -0
- data/lib/capistrano/jira/commit_finder.rb +12 -0
- data/lib/capistrano/jira/finder.rb +30 -0
- data/lib/capistrano/jira/issue_finder.rb +8 -15
- data/lib/capistrano/jira/version.rb +1 -1
- data/lib/capistrano/tasks/jira.rake +30 -12
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23ffb16ae911a6116dec0b954f7a89019eb8d2fa
|
4
|
+
data.tar.gz: 54ba25bf57f58e6dd02d2a14a183747afea81e08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3202cd4e0b5dc9383014b7b8dd04e0fb2c0d9b5aef076953f1914c23d0330ae505686a8ad612e64f72120373a6b71ff1421c947c33b103cddea7c6d7ec7627d
|
7
|
+
data.tar.gz: fdc9339bc4d210de20dd16c8131c5dce5e80e6b3b4e0b4a384021aa37b3a23f3a087c83c0e59f88b372dad68a51d27c3bfb9f61165dc1709a4eef243a7f86d38
|
data/.gitignore
CHANGED
data/Changelog.md
CHANGED
data/README.md
CHANGED
@@ -28,11 +28,13 @@ require 'capistrano/jira'
|
|
28
28
|
|
29
29
|
- Set general parameters in `config/deploy.rb`
|
30
30
|
```ruby
|
31
|
-
set :jira_username,
|
32
|
-
set :jira_password,
|
33
|
-
set :jira_site,
|
34
|
-
set :jira_comment_on_transition,
|
35
|
-
set :jira_project_key,
|
31
|
+
set :jira_username, 'john.doe@exalmple.com' # default: ENV['CAPISTRANO_JIRA_USERNAME']
|
32
|
+
set :jira_password, 'p@55w0rD' # default: ENV['CAPISTRANO_JIRA_PASSWORD']
|
33
|
+
set :jira_site, 'https://example.atlassian.net' # default: ENV['CAPISTRANO_JIRA_SITE']
|
34
|
+
set :jira_comment_on_transition, false # default: true
|
35
|
+
set :jira_project_key, 'PROJ' # required
|
36
|
+
set :jira_validate_commit_messages, true # default: false; transit issues only if key found in commit messages
|
37
|
+
set :jira_commit_messages_limit, 123 # default: 1000; last commits messages lookup limit
|
36
38
|
```
|
37
39
|
|
38
40
|
- Set parameters for specific environment (for example `config/deploy/staging.rb`)
|
data/capistrano-jira.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'capistrano/jira/version'
|
@@ -17,9 +16,10 @@ Gem::Specification.new do |spec|
|
|
17
16
|
.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
17
|
spec.require_paths = ['lib']
|
19
18
|
|
20
|
-
spec.add_dependency 'capistrano', '~> 3.7'
|
21
|
-
spec.add_dependency 'jira-ruby', '~> 1.2'
|
19
|
+
spec.add_dependency 'capistrano' , '~> 3.7'
|
20
|
+
spec.add_dependency 'jira-ruby' , '~> 1.2'
|
21
|
+
spec.add_dependency 'activesupport', '~> 5.1'
|
22
22
|
|
23
23
|
spec.add_development_dependency 'bundler', '~> 1.12'
|
24
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
spec.add_development_dependency 'rake' , '~> 10.0'
|
25
25
|
end
|
data/lib/capistrano/jira.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
+
require 'active_support'
|
1
2
|
require 'capistrano/jira/version'
|
2
3
|
require 'capistrano/jira/errors'
|
4
|
+
require 'capistrano/jira/commit'
|
5
|
+
require 'capistrano/jira/finder'
|
6
|
+
require 'capistrano/jira/commit_finder'
|
3
7
|
require 'capistrano/jira/issue_finder'
|
4
8
|
require 'capistrano/jira/issue_transiter'
|
5
9
|
require 'jira-ruby'
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Capistrano
|
2
|
+
module Jira
|
3
|
+
module Finder
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
attr_reader :items
|
8
|
+
|
9
|
+
def find!
|
10
|
+
return unless self.class.finder_block
|
11
|
+
@items = self.class.finder_block.call
|
12
|
+
end
|
13
|
+
|
14
|
+
def find
|
15
|
+
return unless self.class.finder_block
|
16
|
+
@items ||= self.class.finder_block.call
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class_methods do
|
21
|
+
attr_reader :finder_block
|
22
|
+
|
23
|
+
def execute(&block)
|
24
|
+
return unless block_given?
|
25
|
+
@finder_block = block
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,33 +1,26 @@
|
|
1
1
|
module Capistrano
|
2
2
|
module Jira
|
3
3
|
class IssueFinder
|
4
|
-
|
5
|
-
|
4
|
+
include Finder
|
6
5
|
include ErrorHelpers
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
7
|
+
execute do
|
8
|
+
begin
|
9
|
+
Jira.client.Issue.jql(jql, fields: ['status'], max_results: 1_000_000)
|
10
|
+
rescue JIRA::HTTPError => e
|
11
|
+
raise FinderError, error_message(e)
|
12
|
+
end
|
14
13
|
end
|
15
14
|
|
16
15
|
private
|
17
16
|
|
18
|
-
def jql
|
17
|
+
def self.jql
|
19
18
|
[
|
20
19
|
"project = #{fetch(:jira_project_key)}",
|
21
20
|
"status = #{fetch(:jira_status_name)}",
|
22
21
|
fetch(:jira_filter_jql)
|
23
22
|
].compact.join(' AND ')
|
24
23
|
end
|
25
|
-
|
26
|
-
def execute
|
27
|
-
Jira.client.Issue.jql(jql, fields: ['status'], max_results: 1_000_000)
|
28
|
-
rescue JIRA::HTTPError => e
|
29
|
-
raise FinderError, error_message(e)
|
30
|
-
end
|
31
24
|
end
|
32
25
|
end
|
33
26
|
end
|
@@ -1,13 +1,15 @@
|
|
1
1
|
namespace :load do
|
2
2
|
task :defaults do
|
3
|
-
set :jira_username,
|
4
|
-
set :jira_password,
|
5
|
-
set :jira_site,
|
6
|
-
set :jira_project_key,
|
7
|
-
set :jira_status_name,
|
8
|
-
set :jira_transition_name,
|
9
|
-
set :jira_filter_jql,
|
10
|
-
set :jira_comment_on_transition,
|
3
|
+
set :jira_username, ENV['CAPISTRANO_JIRA_USERNAME']
|
4
|
+
set :jira_password, ENV['CAPISTRANO_JIRA_PASSWORD']
|
5
|
+
set :jira_site, ENV['CAPISTRANO_JIRA_SITE']
|
6
|
+
set :jira_project_key, nil
|
7
|
+
set :jira_status_name, nil
|
8
|
+
set :jira_transition_name, nil
|
9
|
+
set :jira_filter_jql, nil
|
10
|
+
set :jira_comment_on_transition, true
|
11
|
+
set :jira_validate_commit_messages, false
|
12
|
+
set :jira_commit_messages_limit, 1000
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
@@ -15,13 +17,29 @@ namespace :jira do
|
|
15
17
|
desc 'Find and transit possible JIRA issues'
|
16
18
|
task :find_and_transit do |_t|
|
17
19
|
on :all do |_host|
|
20
|
+
if fetch(:jira_validate_commit_messages)
|
21
|
+
info 'Finding commit messages'
|
22
|
+
commits = Capistrano::Jira::CommitFinder.new.find
|
23
|
+
end
|
24
|
+
|
18
25
|
info 'Looking for issues'
|
19
26
|
begin
|
20
27
|
issues = Capistrano::Jira::IssueFinder.new.find
|
28
|
+
|
21
29
|
issues.each do |issue|
|
22
30
|
begin
|
23
|
-
|
24
|
-
|
31
|
+
if fetch(:jira_validate_commit_messages)
|
32
|
+
commit = commits.find { |c| c.message.include?(issue.key)}
|
33
|
+
if commit
|
34
|
+
Capistrano::Jira::IssueTransiter.new(issue).transit
|
35
|
+
info "#{issue.key}\t\u{2713} Transited\tCommit: #{commit.hash}"
|
36
|
+
else
|
37
|
+
info "#{issue.key}\t\u{21B7} Skipped"
|
38
|
+
end
|
39
|
+
else
|
40
|
+
Capistrano::Jira::IssueTransiter.new(issue).transit
|
41
|
+
info "#{issue.key}\t\u{2713} Transited"
|
42
|
+
end
|
25
43
|
rescue Capistrano::Jira::TransitionError => e
|
26
44
|
warn "#{issue.key}\t\u{2717} #{e.message}"
|
27
45
|
end
|
@@ -36,8 +54,8 @@ namespace :jira do
|
|
36
54
|
task :check do
|
37
55
|
errored = false
|
38
56
|
required_params =
|
39
|
-
%i
|
40
|
-
jira_status_name jira_transition_name jira_comment_on_transition
|
57
|
+
%i[jira_username jira_password jira_site jira_project_key
|
58
|
+
jira_status_name jira_transition_name jira_comment_on_transition]
|
41
59
|
|
42
60
|
puts '=> Required params'
|
43
61
|
required_params.each do |param|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-jira
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wojciech Widenka
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.1'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.1'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,7 +96,10 @@ files:
|
|
82
96
|
- capistrano-jira.gemspec
|
83
97
|
- lib/capistrano-jira.rb
|
84
98
|
- lib/capistrano/jira.rb
|
99
|
+
- lib/capistrano/jira/commit.rb
|
100
|
+
- lib/capistrano/jira/commit_finder.rb
|
85
101
|
- lib/capistrano/jira/errors.rb
|
102
|
+
- lib/capistrano/jira/finder.rb
|
86
103
|
- lib/capistrano/jira/issue_finder.rb
|
87
104
|
- lib/capistrano/jira/issue_transiter.rb
|
88
105
|
- lib/capistrano/jira/version.rb
|
@@ -106,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
123
|
version: '0'
|
107
124
|
requirements: []
|
108
125
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.
|
126
|
+
rubygems_version: 2.6.14
|
110
127
|
signing_key:
|
111
128
|
specification_version: 4
|
112
129
|
summary: Automated JIRA issues transitions after deployment with Capistrano
|