capistrano-jira 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +13 -0
- data/README.md +5 -5
- data/Rakefile +0 -5
- data/capistrano-jira.gemspec +2 -4
- data/lib/capistrano-jira.rb +0 -0
- data/lib/capistrano/jira/errors.rb +12 -0
- data/lib/capistrano/jira/issue_finder.rb +3 -3
- data/lib/capistrano/jira/issue_transiter.rb +21 -8
- data/lib/capistrano/jira/version.rb +1 -1
- data/lib/capistrano/tasks/jira.rake +25 -16
- metadata +12 -27
- data/.travis.yml +0 -5
- data/bin/console +0 -14
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca992eb03cd4d34fe9624b50930ad8d32d7fa5cc
|
4
|
+
data.tar.gz: 7dfd66877aab0380606fc9d067180f3437611bfd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35d7cac445e0a03a37f8b560577bd8fc06e1b9c1ef1541182e346b8f4b49f7a858dbcf260c3e809bb1c8af9f0b2d5defe2c1030af0abf39f88e9c72cb30cde70
|
7
|
+
data.tar.gz: 600204753da6c7e156118f432ae7871e96876693693c9aa462001d60ad7161a90c6c7b0082accc4a2119a7bf6f450ade8d7109feb574a46fc06c6f67523325f0
|
data/Changelog.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
## 0.2.0
|
2
|
+
|
3
|
+
- Handle errors without exiting deployment (*wojw5*, #2)
|
4
|
+
- Add comment on transition
|
5
|
+
- Use capistrano output methods
|
6
|
+
- remove rspec - there are no tests
|
7
|
+
- remove travis CI - not needed
|
8
|
+
- lock versions
|
9
|
+
|
10
|
+
|
11
|
+
## 0.1.0
|
12
|
+
|
13
|
+
- Initial release (*wojw5*, #1)
|
data/README.md
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
[![Build Status](https://travis-ci.org/wojw5/capistrano-jira.svg?branch=master)](https://travis-ci.org/wojw5/capistrano-jira)
|
2
1
|
[![Code Climate](https://codeclimate.com/github/wojw5/capistrano-jira/badges/gpa.svg)](https://codeclimate.com/github/wojw5/capistrano-jira)
|
3
2
|
# Capistrano::Jira
|
4
3
|
|
@@ -29,10 +28,11 @@ require 'capistrano/jira'
|
|
29
28
|
|
30
29
|
- Set general parameters in `config/deploy.rb`
|
31
30
|
```ruby
|
32
|
-
set :jira_username,
|
33
|
-
set :jira_password,
|
34
|
-
set :jira_site,
|
35
|
-
set :
|
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
36
|
```
|
37
37
|
|
38
38
|
- Set parameters for specific environment (for example `config/deploy/staging.rb`)
|
data/Rakefile
CHANGED
data/capistrano-jira.gemspec
CHANGED
@@ -15,13 +15,11 @@ Gem::Specification.new do |spec|
|
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`
|
17
17
|
.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
18
|
spec.require_paths = ['lib']
|
20
19
|
|
21
|
-
spec.add_dependency 'capistrano'
|
22
|
-
spec.add_dependency 'jira-ruby'
|
20
|
+
spec.add_dependency 'capistrano', '~> 3.7'
|
21
|
+
spec.add_dependency 'jira-ruby', '~> 1.2'
|
23
22
|
|
24
23
|
spec.add_development_dependency 'bundler', '~> 1.12'
|
25
24
|
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
27
25
|
end
|
File without changes
|
@@ -2,5 +2,17 @@ module Capistrano
|
|
2
2
|
module Jira
|
3
3
|
class TransitionError < StandardError; end
|
4
4
|
class FinderError < StandardError; end
|
5
|
+
|
6
|
+
module ErrorHelpers
|
7
|
+
def error_message(e)
|
8
|
+
case e
|
9
|
+
when JIRA::HTTPError
|
10
|
+
r = e.response
|
11
|
+
"#{r.class.name}; #{r.code}: #{r.message} \n #{r.body}"
|
12
|
+
else
|
13
|
+
e.message
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
5
17
|
end
|
6
18
|
end
|
@@ -3,6 +3,8 @@ module Capistrano
|
|
3
3
|
class IssueFinder
|
4
4
|
attr_reader :issues
|
5
5
|
|
6
|
+
include ErrorHelpers
|
7
|
+
|
6
8
|
def find!
|
7
9
|
@issues = execute
|
8
10
|
end
|
@@ -24,9 +26,7 @@ module Capistrano
|
|
24
26
|
def execute
|
25
27
|
Jira.client.Issue.jql(jql, fields: ['status'], max_results: 1_000_000)
|
26
28
|
rescue JIRA::HTTPError => e
|
27
|
-
|
28
|
-
raise FinderError,
|
29
|
-
"#{r.class.name}; #{r.code}: #{r.message} \n #{r.body}"
|
29
|
+
raise FinderError, error_message(e)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -21,18 +21,31 @@ module Capistrano
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def validate_transition
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
24
|
+
return if transition
|
25
|
+
raise TransitionError,
|
26
|
+
"Transition #{fetch(:jira_transition_name)} not available"
|
28
27
|
end
|
29
28
|
|
30
29
|
def execute
|
31
|
-
issue.transitions.build.save!(
|
30
|
+
issue.transitions.build.save!(transition_hash)
|
32
31
|
rescue JIRA::HTTPError => e
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
raise TransitionError, error_message(e)
|
33
|
+
end
|
34
|
+
|
35
|
+
def transition_hash
|
36
|
+
hash = { transition: { id: transition.id } }
|
37
|
+
hash.merge(comment_hash) if fetch(:jira_comment_on_transition)
|
38
|
+
hash
|
39
|
+
end
|
40
|
+
|
41
|
+
def comment_hash
|
42
|
+
{ update:
|
43
|
+
{ comment: [
|
44
|
+
{ add:
|
45
|
+
{
|
46
|
+
body: 'Issue transited automatically during deployment.'
|
47
|
+
} }
|
48
|
+
] } }
|
36
49
|
end
|
37
50
|
end
|
38
51
|
end
|
@@ -1,26 +1,33 @@
|
|
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,
|
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
|
10
11
|
end
|
11
12
|
end
|
12
13
|
|
13
14
|
namespace :jira do
|
14
15
|
desc 'Find and transit possible JIRA issues'
|
15
16
|
task :find_and_transit do |_t|
|
16
|
-
|
17
|
-
|
18
|
-
issues.each do |issue|
|
17
|
+
on :all do |_host|
|
18
|
+
info 'Looking for issues'
|
19
19
|
begin
|
20
|
-
Capistrano::Jira::
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
issues = Capistrano::Jira::IssueFinder.new.find
|
21
|
+
issues.each do |issue|
|
22
|
+
begin
|
23
|
+
Capistrano::Jira::IssueTransiter.new(issue).transit
|
24
|
+
info "#{issue.key}\t\u{2713} Transited"
|
25
|
+
rescue Capistrano::Jira::TransitionError => e
|
26
|
+
warn "#{issue.key}\t\u{2717} #{e.message}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
rescue Capistrano::Jira::FinderError => e
|
30
|
+
error "#{e.class} #{e.message}"
|
24
31
|
end
|
25
32
|
end
|
26
33
|
end
|
@@ -28,8 +35,10 @@ namespace :jira do
|
|
28
35
|
desc 'Check JIRA setup'
|
29
36
|
task :check do
|
30
37
|
errored = false
|
31
|
-
required_params =
|
32
|
-
|
38
|
+
required_params =
|
39
|
+
%i(jira_username jira_password jira_site jira_project_key
|
40
|
+
jira_status_name jira_transition_name jira_comment_on_transition)
|
41
|
+
|
33
42
|
puts '=> Required params'
|
34
43
|
required_params.each do |param|
|
35
44
|
print "#{param} = "
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-jira
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
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: 2017-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3.7'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '3.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: jira-ruby
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '1.2'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '1.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '10.0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rspec
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '3.0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '3.0'
|
83
69
|
description:
|
84
70
|
email:
|
85
71
|
- wojtek@codegarden.online
|
@@ -89,13 +75,12 @@ extra_rdoc_files: []
|
|
89
75
|
files:
|
90
76
|
- ".gitignore"
|
91
77
|
- ".rspec"
|
92
|
-
-
|
78
|
+
- Changelog.md
|
93
79
|
- Gemfile
|
94
80
|
- README.md
|
95
81
|
- Rakefile
|
96
|
-
- bin/console
|
97
|
-
- bin/setup
|
98
82
|
- capistrano-jira.gemspec
|
83
|
+
- lib/capistrano-jira.rb
|
99
84
|
- lib/capistrano/jira.rb
|
100
85
|
- lib/capistrano/jira/errors.rb
|
101
86
|
- lib/capistrano/jira/issue_finder.rb
|
data/.travis.yml
DELETED
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'bundler/setup'
|
4
|
-
require 'capistrano/jira'
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require 'irb'
|
14
|
-
IRB.start
|