capistrano-redmine 0.0.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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +79 -0
- data/Rakefile +2 -0
- data/capistrano-redmine.gemspec +16 -0
- data/lib/capistrano-redmine/common.rb +86 -0
- data/lib/capistrano-redmine/redmine_client.rb +20 -0
- data/lib/capistrano-redmine.rb +5 -0
- metadata +56 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Aleksey Kurepin
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
# capistrano-redmine
|
2
|
+
|
3
|
+
This gem contains a Capistrano :task, which allows to update the Redmine issues
|
4
|
+
statuses when you do deploy with Capistrano. For example, to change issues
|
5
|
+
status from "Waiting for deploy" to "Waiting for review."
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'capistrano-redmine'
|
12
|
+
|
13
|
+
or
|
14
|
+
|
15
|
+
gem 'capistrano-redmine', :git => 'git://github.com/foxweb/capistrano-redmine.git'
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle install
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install capistrano-redmine
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
1. Install and config you [Capistrano](https://github.com/capistrano/capistrano/) utility.
|
28
|
+
2. Install _capistrano-redmine_.
|
29
|
+
3. Change directory to RAILS_ROOT of your app.
|
30
|
+
3. Add this variables in `config/deploy.rb`:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
# settings for capistrano-redmine
|
34
|
+
set :redmine_site, "http://localhost:3000" # Redmine app host and port
|
35
|
+
set :redmine_token, "376ba30fca80867d10a0ec0b505e5c97834901e3" # Redmine API key
|
36
|
+
set :redmine_projects, "test-project" # you project identifier or array of.
|
37
|
+
set :redmine_from_status, 1 # Redmine status ID "from"
|
38
|
+
set :redmine_to_status, 3 # Redmine status ID "to"
|
39
|
+
require "capistrano-redmine"
|
40
|
+
```
|
41
|
+
|
42
|
+
and
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
after "deploy", "redmine:update"
|
46
|
+
```
|
47
|
+
|
48
|
+
Specify the necessary settings for your Redmine.
|
49
|
+
|
50
|
+
4. Check installation with command
|
51
|
+
|
52
|
+
`bundle exec cap -T redmine`
|
53
|
+
|
54
|
+
You should see line:
|
55
|
+
|
56
|
+
`cap redmine:update # Update Redmine issues statuses.`
|
57
|
+
|
58
|
+
5. Start `bundle exec cap deploy` or `bundle exec cap redmine:update`.
|
59
|
+
6. Check your Redmine issues and enjoy it!
|
60
|
+
|
61
|
+
## Redmine API config
|
62
|
+
|
63
|
+
1. To enable the API-style authentication, you have to check Enable REST API in Administration → Settings → Authentication.
|
64
|
+
2. Create new user named like 'deploy' (or other) and login with this.
|
65
|
+
3. You can find your API key on your account page ( /my/account ) when logged in, on the right-hand pane of the default layout.
|
66
|
+
4. Copy and paste API key to the `config/deploy.rb` on `set :redmine_token`.
|
67
|
+
|
68
|
+
## Documentation
|
69
|
+
|
70
|
+
* [Capistrano Wiki](http://github.com/capistrano/capistrano/wiki/)
|
71
|
+
* [Redmine API](http://www.redmine.org/projects/redmine/wiki/Rest_api)
|
72
|
+
|
73
|
+
## Contributing
|
74
|
+
|
75
|
+
1. Fork it.
|
76
|
+
2. Create your feature branch (`git checkout -b my-new-feature`).
|
77
|
+
3. Commit your changes (`git commit -am 'Added some feature'`).
|
78
|
+
4. Push to the branch (`git push origin my-new-feature`).
|
79
|
+
5. Create new Pull Request.
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
Gem::Specification.new do |gem|
|
3
|
+
gem.authors = ["Aleksey Kurepin"]
|
4
|
+
gem.email = ["lesha@kurepin.com"]
|
5
|
+
gem.description = %q{This gem contains a Capistrano :task, which allows to
|
6
|
+
update the Redmine issues statuses when you do deploy with Capistrano.}
|
7
|
+
gem.summary = %q{Update Redmine issues statuses on Capistrano deploy.}
|
8
|
+
gem.homepage = "http://github.com/foxweb/capistrano-redmine"
|
9
|
+
|
10
|
+
gem.files = `git ls-files`.split($\)
|
11
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
12
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
13
|
+
gem.name = "capistrano-redmine"
|
14
|
+
gem.require_paths = ["lib"]
|
15
|
+
gem.version = "0.0.1"
|
16
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
module Capistrano
|
3
|
+
module Redmine
|
4
|
+
|
5
|
+
def Redmine.configure(site, token)
|
6
|
+
RedmineClient::Base.configure do
|
7
|
+
self.site = site
|
8
|
+
self.format = :xml
|
9
|
+
self.user = token
|
10
|
+
self.password = ""
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def Redmine.update(site, token, projects, from_status, to_status, logger)
|
15
|
+
Redmine.configure(site, token)
|
16
|
+
projects = [projects] unless projects.is_a? Array
|
17
|
+
|
18
|
+
projects.each do |p|
|
19
|
+
|
20
|
+
unless p.is_a? String
|
21
|
+
logger.important "Redmine error: Argument 'redmine_projects' type error."
|
22
|
+
return
|
23
|
+
end
|
24
|
+
|
25
|
+
begin
|
26
|
+
RedmineClient::Project.find(p)
|
27
|
+
rescue ActiveResource::UnauthorizedAccess
|
28
|
+
logger.important "Redmine error: Unauthorized Access. Check token."
|
29
|
+
return
|
30
|
+
rescue ActiveResource::ResourceNotFound
|
31
|
+
logger.important "Redmine error: Project not found."
|
32
|
+
return
|
33
|
+
end
|
34
|
+
|
35
|
+
statuses = RedmineClient::IssueStatus.find(:all).inject({}) do |memo, s|
|
36
|
+
memo.merge s.id => s.name
|
37
|
+
end
|
38
|
+
|
39
|
+
if statuses[from_status.to_s].nil? || statuses[to_status.to_s].nil?
|
40
|
+
logger.important "Redmine error: Invalid issue status (or statuses)."
|
41
|
+
return
|
42
|
+
end
|
43
|
+
|
44
|
+
begin
|
45
|
+
issues = RedmineClient::Issue.find(:all, :params => {
|
46
|
+
:project_id => p,
|
47
|
+
:status_id => from_status,
|
48
|
+
:limit => 100
|
49
|
+
}
|
50
|
+
)
|
51
|
+
|
52
|
+
issues.each do |i|
|
53
|
+
i.status_id = to_status
|
54
|
+
i.save
|
55
|
+
logger.debug "Update ##{i.id} #{i.subject}"
|
56
|
+
end
|
57
|
+
rescue ActiveResource::ResourceInvalid
|
58
|
+
logger.important "Redmine error: Update issue error."
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
67
|
+
Capistrano::Configuration.instance(:must_exist) :
|
68
|
+
Capistrano.configuration(:must_exist)
|
69
|
+
|
70
|
+
configuration.load do
|
71
|
+
|
72
|
+
namespace :redmine do
|
73
|
+
desc "Update Redmine issues statuses."
|
74
|
+
task :update, :roles => :app, :except => { :no_release => true } do
|
75
|
+
Capistrano::Redmine.update(
|
76
|
+
redmine_site,
|
77
|
+
redmine_token,
|
78
|
+
redmine_projects,
|
79
|
+
redmine_from_status,
|
80
|
+
redmine_to_status,
|
81
|
+
logger
|
82
|
+
)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
module RedmineClient
|
3
|
+
class Base < ActiveResource::Base
|
4
|
+
|
5
|
+
def self.configure(&block)
|
6
|
+
instance_eval &block
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
class Project < RedmineClient::Base
|
12
|
+
end
|
13
|
+
|
14
|
+
class Issue < RedmineClient::Base
|
15
|
+
end
|
16
|
+
|
17
|
+
class IssueStatus < RedmineClient::Base
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-redmine
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Aleksey Kurepin
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-05 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: ! "This gem contains a Capistrano :task, which allows to\n update
|
15
|
+
the Redmine issues statuses when you do deploy with Capistrano."
|
16
|
+
email:
|
17
|
+
- lesha@kurepin.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- .gitignore
|
23
|
+
- Gemfile
|
24
|
+
- LICENSE
|
25
|
+
- README.md
|
26
|
+
- Rakefile
|
27
|
+
- capistrano-redmine.gemspec
|
28
|
+
- lib/capistrano-redmine.rb
|
29
|
+
- lib/capistrano-redmine/common.rb
|
30
|
+
- lib/capistrano-redmine/redmine_client.rb
|
31
|
+
homepage: http://github.com/foxweb/capistrano-redmine
|
32
|
+
licenses: []
|
33
|
+
post_install_message:
|
34
|
+
rdoc_options: []
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ! '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
requirements: []
|
50
|
+
rubyforge_project:
|
51
|
+
rubygems_version: 1.8.24
|
52
|
+
signing_key:
|
53
|
+
specification_version: 3
|
54
|
+
summary: Update Redmine issues statuses on Capistrano deploy.
|
55
|
+
test_files: []
|
56
|
+
has_rdoc:
|