capistrano-stride 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 666372ae1ccc23611acdea1764010c6e7ee10680
4
+ data.tar.gz: f42d2da5b60e41a6282894f884061469318fdc10
5
+ SHA512:
6
+ metadata.gz: 3757aece67c2e198de1a2238f35987a29b5ecf01bcce65043e1b261b8f4d8f095652f533eadd92c64d7eda5005ac29bfb03d5cbf5928faaaf17379f712e1735c
7
+ data.tar.gz: 9c4a1600e66895618473b595624e3279aaf64934fa5f8b5e98e00147b77237deffc43180514eff50fa6cae5548ab3adbcf886e76ab7a4ba9c2b2e7e982874a83
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ Gemfile.lock
2
+ .idea
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ sudo: false
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.4.1
6
+ - 2.3.0
7
+ - 2.2.4
8
+ - 2.1.7
9
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-stride.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Restorando
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,57 @@
1
+ # Capistrano::Stride
2
+
3
+ [![Maintainability](https://api.codeclimate.com/v1/badges/2aa1419d1454294270fb/maintainability)](https://codeclimate.com/github/ArsenBespalov/capistrano-stride/maintainability)
4
+ [![Build Status](https://travis-ci.org/ArsenBespalov/capistrano-stride.svg?branch=master)](https://travis-ci.org/ArsenBespalov/capistrano-stride)
5
+
6
+ Notifies in a Stride room about a new deployment showing the git log for the latest
7
+ commits included in the current deploy.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ group :deployment do
15
+ gem 'capistrano-stride'
16
+ end
17
+ ```
18
+
19
+ The group declaration is optional, but it's important to make sure you only load this gem
20
+ withing a Capistrano script (as explained below) and never within your application
21
+ (eg. rails does the require of the default bundler group and the current environment group).
22
+
23
+ And then execute:
24
+
25
+ ```
26
+ $ bundle
27
+ ```
28
+
29
+ Or install it yourself as:
30
+
31
+ ```
32
+ $ gem install capistrano-stride
33
+ ```
34
+
35
+ ## Usage
36
+
37
+ Add this to your `Capfile`
38
+
39
+ ```ruby
40
+ require 'capistrano/stride'
41
+ ```
42
+
43
+ Then you need to configure you Stride token and the room URL you want to notify about
44
+ the new deployment
45
+
46
+ ```ruby
47
+ set :stride_token, "YOUR TOKEN"
48
+ set :stride_url, "https://api.atlassian.com/site/site_id/conversation/conversation_id/message"
49
+ ```
50
+
51
+ ## Contributing
52
+
53
+ 1. Fork it
54
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
55
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
56
+ 4. Push to the branch (`git push origin my-new-feature`)
57
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'capistrano/stride/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "capistrano-stride"
8
+ spec.version = Capistrano::Stride::VERSION
9
+ spec.author = "Arsen Bespalov"
10
+ spec.email = "a@spadix.ru"
11
+ spec.description = %q{Notify to Stride about deployments}
12
+ spec.summary = %Q{Notifies in a Stride room about a new deployment showing the git log\nfor the latests commits inclided in the current deploy.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.required_ruby_version = '>= 2.0.0'
17
+
18
+ spec.files = `git ls-files`.split($/)
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_dependency "capistrano", "~> 3.2"
24
+ spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "rake"
26
+ end
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module Stride
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ require 'capistrano/stride/version'
2
+
3
+ load File.expand_path('../tasks/stride.rake', __FILE__)
@@ -0,0 +1,104 @@
1
+ namespace :stride do
2
+ task :notify_deploy_failed do
3
+ message = "#{fetch(:local_user, local_user).strip} cancelled deployment of #{fetch(:application)} to #{fetch(:stage)}."
4
+
5
+ request = fetch(:request)
6
+ body = {
7
+ body: {
8
+ version: 1,
9
+ type: "doc",
10
+ content: [
11
+ {
12
+ type: "paragraph",
13
+ content: [
14
+ {
15
+ type: "text",
16
+ text: message
17
+ }
18
+ ]
19
+ }
20
+ ]
21
+ }
22
+ }
23
+ request.body = body.to_json
24
+
25
+ fetch(:http).request(request)
26
+ end
27
+
28
+ task :notify_deploy_started do
29
+ commits = `git log --no-color --max-count=5 --pretty=format:' - %an: %s' --abbrev-commit --no-merges #{fetch(:previous_revision, "HEAD")}..#{fetch(:current_revision, "HEAD")}`
30
+ commits.gsub!("\n", "<br />")
31
+ message = "#{fetch(:local_user, local_user).strip} is deploying #{fetch(:application)} to #{fetch(:stage)} <br />"
32
+ message << commits
33
+
34
+ request = fetch(:request)
35
+ body = {
36
+ body: {
37
+ version: 1,
38
+ type: "doc",
39
+ content: [
40
+ {
41
+ type: "paragraph",
42
+ content: [
43
+ {
44
+ type: "text",
45
+ text: message
46
+ }
47
+ ]
48
+ }
49
+ ]
50
+ }
51
+ }
52
+ request.body = body.to_json
53
+
54
+ fetch(:http).request(request)
55
+ end
56
+
57
+ task :notify_deploy_finished do
58
+ message = "#{fetch(:local_user, local_user).strip} finished deploying #{fetch(:application)} to #{fetch(:stage)}."
59
+
60
+ request = fetch(:request)
61
+ body = {
62
+ body: {
63
+ version: 1,
64
+ type: "doc",
65
+ content: [
66
+ {
67
+ type: "paragraph",
68
+ content: [
69
+ {
70
+ type: "text",
71
+ text: message
72
+ }
73
+ ]
74
+ }
75
+ ]
76
+ }
77
+ }
78
+ request.body = body.to_json
79
+
80
+ fetch(:http).request(request)
81
+ end
82
+
83
+ before "deploy:updated", "stride:notify_deploy_started"
84
+ after "deploy:finished", "stride:notify_deploy_finished"
85
+ before "deploy:reverted", "stride:notify_deploy_failed"
86
+ end
87
+
88
+ namespace :load do
89
+ task :defaults do
90
+ require 'net/http'
91
+ require 'uri'
92
+ require 'json'
93
+
94
+ uri = URI.parse(fetch(:stride_url))
95
+
96
+ header = {
97
+ 'Content-Type': 'text/json',
98
+ 'Authorization': "Bearer #{fetch(:stride_token)}"
99
+ }
100
+
101
+ set(:http, -> { Net::HTTP.new(uri.host, uri.port) })
102
+ set(:request, -> { Net::HTTP::Post.new(uri.request_uri, header) })
103
+ end
104
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-stride
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Arsen Bespalov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-04-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Notify to Stride about deployments
56
+ email: a@spadix.ru
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - ".gitignore"
62
+ - ".travis.yml"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - capistrano-stride.gemspec
68
+ - lib/capistrano/stride.rb
69
+ - lib/capistrano/stride/version.rb
70
+ - lib/capistrano/tasks/stride.rake
71
+ homepage: ''
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: 2.0.0
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.6.14
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Notifies in a Stride room about a new deployment showing the git log for
95
+ the latests commits inclided in the current deploy.
96
+ test_files: []