capistrano-stride 0.1.0 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 694c8d1218a5de2361515628fb3179266393b356
4
- data.tar.gz: 955dee4dcde5a6cb2ff6953cf2738b054956cfeb
3
+ metadata.gz: 7261e7f7f16f7efff6ea82a1dbf23bf73cc3cd04
4
+ data.tar.gz: 69ff82a7351534f0dff77a04fdb69d706b600973
5
5
  SHA512:
6
- metadata.gz: b50541b445213df1c3a3ec2749b04f3dd13734ce27f2fa0b0b13663e75037c09b8dfe8a4564b9f5bda0f33401c40d73bd739098a174bea0c5044a738d206b36a
7
- data.tar.gz: bafed133d2af67a483e736ac309e1616ae9b3eaa85a4719410a14a102555363e125621f39a24355beaf6530ab66d29c0b13ce642217d6b815fd923d85a196f84
6
+ metadata.gz: 167dd19cbea197ecbbe966cb669152b9c95c3c085dd2b2d3144bd8bd9b300196f6b7bc57044aa6600ac6e31e14bcb7b15afc2ff87d336026967a733f9ff5227f
7
+ data.tar.gz: c454c4a7af43c1398a6a1cb2537cd28f5cd94ecff6eb4c6c418815bb9e3c33967a51cbffa9abb3ba2e961a934af9e52e6b9c2049eeff462c6ef5410aa2ae6a75
data/README.md CHANGED
@@ -13,7 +13,7 @@ Add this line to your application's Gemfile:
13
13
 
14
14
  ```ruby
15
15
  group :deployment do
16
- gem 'capistrano-stride'
16
+ gem 'capistrano-stride', '~> 0.2', require: false
17
17
  end
18
18
  ```
19
19
 
@@ -45,10 +45,14 @@ Then you need to configure you Stride token and the room URL you want to notify
45
45
  the new deployment
46
46
 
47
47
  ```ruby
48
- set :stride_token, "YOUR TOKEN"
49
48
  set :stride_url, "https://api.atlassian.com/site/site_id/conversation/conversation_id/message"
49
+ set :stride_token, "STRIDE_ACCESS_TOKEN"
50
50
  ```
51
51
 
52
+ For get Stride URL and access token you need add custom app with API tokens,
53
+ without installation application. Just only enter specify a token name. Simple and Easy!
54
+
55
+
52
56
  ## Contributing
53
57
 
54
58
  1. Fork it
@@ -21,7 +21,6 @@ Gem::Specification.new do |spec|
21
21
  spec.require_paths = ["lib"]
22
22
 
23
23
  spec.add_dependency "capistrano", "~> 3.2"
24
- spec.add_dependency "stride"
25
24
  spec.add_development_dependency "bundler", "~> 1.3"
26
25
  spec.add_development_dependency "rake"
27
26
  end
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Stride
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -1,115 +1,144 @@
1
+ require 'uri'
2
+ require 'net/http'
3
+ require 'net/https'
4
+ require 'json'
5
+
1
6
  namespace :stride do
2
7
  task :notify_deploy_failed do
3
8
  message = "#{fetch(:local_user, local_user).strip} cancelled deployment of #{fetch(:application)} to #{fetch(:stage)}."
4
9
 
5
- message_body = {
6
- version: 1,
7
- type: "doc",
8
- content: [
9
- {
10
- type: "panel",
11
- attrs: {
12
- panelType: "warning"
13
- },
14
- content: [
15
- {
16
- type: "paragraph",
17
- content: [
18
- {
19
- type: "text",
20
- text: message
21
- }
22
- ]
23
- }
24
- ]
25
- }
26
- ]
10
+ body = {
11
+ body: {
12
+ version: 1,
13
+ type: "doc",
14
+ content: [
15
+ {
16
+ type: "panel",
17
+ attrs: {
18
+ panelType: "warning"
19
+ },
20
+ content: [
21
+ {
22
+ type: "paragraph",
23
+ content: [
24
+ {
25
+ type: "text",
26
+ text: message
27
+ }
28
+ ]
29
+ }
30
+ ]
31
+ }
32
+ ]
33
+ }
27
34
  }
28
35
 
29
- fetch(:client).send_message(message_body)
36
+ uri = URI.parse(fetch(:stride_url))
37
+ https = Net::HTTP.new(uri.host, uri.port)
38
+ https.use_ssl = true
39
+ header = {
40
+ 'Content-Type' => 'application/json',
41
+ 'Authorization' => "Bearer #{fetch(:stride_token)}"
42
+ }
43
+ req = Net::HTTP::Post.new(uri.path, header)
44
+ req.body = body.to_json
45
+ https.request(req)
30
46
  end
31
47
 
32
48
  task :notify_deploy_started do
33
49
  commits = `git log --no-color --max-count=5 --pretty=format:' - %an: %s' --abbrev-commit --no-merges #{fetch(:previous_revision, "HEAD")}..#{fetch(:current_revision, "HEAD")}`
34
- # commits.gsub!("\n", "<br />")
35
- message = "#{fetch(:local_user, local_user).strip} is deploying #{fetch(:application)} to #{fetch(:stage)} <br />"
50
+ message = "#{fetch(:local_user, local_user).strip} is deploying #{fetch(:application)} to #{fetch(:stage)} \n"
36
51
 
37
- message_body = {
38
- version: 1,
39
- type: "doc",
40
- content: [
41
- {
42
- type: "panel",
43
- attrs: {
44
- panelType: "info"
45
- },
46
- content: [
47
- {
48
- type: "paragraph",
49
- content: [
50
- {
51
- type: "text",
52
- text: message
53
- },
54
- {
55
- type: "text",
56
- text: commits,
57
- marks: [
58
- {
59
- type: "code"
60
- }
61
- ]
62
- }
63
- ]
64
- }
65
- ]
66
- }
67
- ]
52
+ body = {
53
+ body: {
54
+ version: 1,
55
+ type: "doc",
56
+ content: [
57
+ {
58
+ type: "panel",
59
+ attrs: {
60
+ panelType: "info"
61
+ },
62
+ content: [
63
+ {
64
+ type: "paragraph",
65
+ content: [
66
+ {
67
+ type: "text",
68
+ text: message
69
+ },
70
+ {
71
+ type: "text",
72
+ text: commits,
73
+ marks: [
74
+ {
75
+ type: "code"
76
+ }
77
+ ]
78
+ }
79
+ ]
80
+ }
81
+ ]
82
+ }
83
+ ]
84
+ }
68
85
  }
69
86
 
70
- fetch(:client).send_message(message_body)
87
+ uri = URI.parse(fetch(:stride_url))
88
+ https = Net::HTTP.new(uri.host, uri.port)
89
+ https.use_ssl = true
90
+ header = {
91
+ 'Content-Type' => 'application/json',
92
+ 'Authorization' => "Bearer #{fetch(:stride_token)}"
93
+ }
94
+ req = Net::HTTP::Post.new(uri.path, header)
95
+ req.body = body.to_json
96
+ https.request(req)
71
97
  end
72
98
 
73
99
  task :notify_deploy_finished do
74
100
  message = "#{fetch(:local_user, local_user).strip} finished deploying #{fetch(:application)} to #{fetch(:stage)}."
75
101
 
76
- message_body = {
77
- version: 1,
78
- type: "doc",
79
- content: [
80
- {
81
- type: "panel",
82
- attrs: {
83
- panelType: "note"
84
- },
85
- content: [
86
- {
87
- type: "paragraph",
88
- content: [
89
- {
90
- type: "text",
91
- text: message
92
- }
93
- ]
94
- }
95
- ]
102
+ body = {
103
+ body: {
104
+ version: 1,
105
+ type: "doc",
106
+ content: [
107
+ {
108
+ type: "panel",
109
+ attrs: {
110
+ panelType: "note"
111
+ },
112
+ content: [
113
+ {
114
+ type: "paragraph",
115
+ content: [
116
+ {
117
+ type: "text",
118
+ text: message
119
+ }
120
+ ]
121
+ }
122
+ ]
96
123
 
97
- }
98
- ]
124
+ }
125
+ ]
126
+ }
99
127
  }
100
128
 
101
- fetch(:client).send_message(message_body)
129
+ uri = URI.parse(fetch(:stride_url))
130
+ https = Net::HTTP.new(uri.host, uri.port)
131
+ https.use_ssl = true
132
+ header = {
133
+ 'Content-Type' => 'application/json',
134
+ 'Authorization' => "Bearer #{fetch(:stride_token)}"
135
+ }
136
+ req = Net::HTTP::Post.new(uri.path, header)
137
+ req.body = body.to_json
138
+ https.request(req)
102
139
  end
103
140
 
104
141
  before "deploy:updated", "stride:notify_deploy_started"
105
142
  after "deploy:finished", "stride:notify_deploy_finished"
106
143
  before "deploy:reverted", "stride:notify_deploy_failed"
107
- end
108
-
109
- namespace :load do
110
- task :defaults do
111
- require 'stride'
112
-
113
- set(:client, -> {Stride::Client.new(fetch(:cloud_id), fetch(:conversation_id))})
114
- end
115
144
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-stride
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arsen Bespalov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-16 00:00:00.000000000 Z
11
+ date: 2018-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.2'
27
- - !ruby/object:Gem::Dependency
28
- name: stride
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: bundler
43
29
  requirement: !ruby/object:Gem::Requirement