capistrano-stride 0.2.1 → 0.3.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: 03d3ae503a9b8af3cc03288de7cb14da5bf3ae8e
4
- data.tar.gz: 43eb4b7fa1b8fbb1f99796123882f1963975bcc4
3
+ metadata.gz: b42944ec66bc82377d4f627287ef780fcca0eb59
4
+ data.tar.gz: 43ef8f99caa6521c709cdd6d4410e23404202c29
5
5
  SHA512:
6
- metadata.gz: 7aedc96b5343e4c8f928ecbcdb9bd58e81a29b250fc686ac0e2ec7558593042a11809984f4ba4ca4619bb96bb5c70929fb942c7247620f4add46ad1c68a62ee9
7
- data.tar.gz: fa22b104113d918fc94f5e7f51a35487b2c882966004925cb4be4c0c6e72c66ed8622badfbcd0b6e196da4d56a7c31f614a5f7dc7a35932c968108d190f249c9
6
+ metadata.gz: 39b163013f2c5d7c4db1f2f18973c6ea362aa5c9f0f337ca9657ce117a974d660d45ecc6f8631d6786ef7589d1a1123ccd3b30ca5a6eb7eca834a13553541a63
7
+ data.tar.gz: c371531765661c58a341885a3600a77d630723ad0a10789a6cf1bb2ea86e5316622b319413bd054d8981eabc3039ac0ceca2524a2a5e9ab4b2b2d94afedfaf85
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Stride
3
- VERSION = "0.2.1"
3
+ VERSION = "0.3.0"
4
4
  end
5
- end
5
+ end
@@ -6,139 +6,85 @@ require 'json'
6
6
  namespace :stride do
7
7
  task :notify_deploy_failed do
8
8
  message = "#{fetch(:local_user, local_user).strip} cancelled deployment of #{fetch(:application)} to #{fetch(:stage)}."
9
-
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
- }
34
- }
35
-
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)
9
+ url = fetch(:stride_url)
10
+ token = fetch(:stride_token)
11
+ send(url, token, message, 'removed')
46
12
  end
47
13
 
48
14
  task :notify_deploy_started do
49
15
  commits = `git log --no-color --max-count=5 --pretty=format:' - %an: %s' --abbrev-commit --no-merges #{fetch(:previous_revision, "HEAD")}..#{fetch(:current_revision, "HEAD")}`
50
- message = "#{fetch(:local_user, local_user).strip} is deploying #{fetch(:application)} to #{fetch(:stage)} \n"
16
+ message = "#{fetch(:local_user, local_user).strip} is deploying #{fetch(:application)} to #{fetch(:stage)} \n\n#{commits}"
17
+ url = fetch(:stride_url)
18
+ token = fetch(:stride_token)
19
+ send(url, token, message)
20
+ end
51
21
 
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
- }
85
- }
22
+ task :notify_deploy_finished do
23
+ message = "#{fetch(:local_user, local_user).strip} finished deploying #{fetch(:application)} to #{fetch(:stage)}."
24
+ url = fetch(:stride_url)
25
+ token = fetch(:stride_token)
26
+ send(url, token, message, 'success')
27
+ end
28
+
29
+ before "deploy:updated", "stride:notify_deploy_started"
30
+ after "deploy:finished", "stride:notify_deploy_finished"
31
+ before "deploy:reverted", "stride:notify_deploy_failed"
32
+
33
+ def send(stride_url, stride_token, message = '', status = 'inprogress')
34
+ @status = status
35
+ @message = message
36
+ if status == 'inprogress'
37
+ @status_text = 'Started'
38
+ elsif status == 'success'
39
+ @status_text = 'Successful'
40
+ elsif status == 'removed'
41
+ @status_text = 'Failed'
42
+ else
43
+ @status = 'default'
44
+ @status_text = 'Unknown'
45
+ end
86
46
 
87
- uri = URI.parse(fetch(:stride_url))
47
+ uri = URI.parse(stride_url)
88
48
  https = Net::HTTP.new(uri.host, uri.port)
89
49
  https.use_ssl = true
90
50
  header = {
91
51
  'Content-Type' => 'application/json',
92
- 'Authorization' => "Bearer #{fetch(:stride_token)}"
52
+ 'Authorization' => "Bearer #{stride_token}"
93
53
  }
94
54
  req = Net::HTTP::Post.new(uri.path, header)
95
55
  req.body = body.to_json
96
56
  https.request(req)
97
57
  end
98
58
 
99
- task :notify_deploy_finished do
100
- message = "#{fetch(:local_user, local_user).strip} finished deploying #{fetch(:application)} to #{fetch(:stage)}."
101
-
102
- body = {
59
+ def body
60
+ {
103
61
  body: {
104
62
  version: 1,
105
- type: "doc",
63
+ type: 'doc',
106
64
  content: [
107
65
  {
108
- type: "panel",
66
+ type: 'applicationCard',
109
67
  attrs: {
110
- panelType: "note"
111
- },
112
- content: [
113
- {
114
- type: "paragraph",
115
- content: [
116
- {
117
- type: "text",
118
- text: message
68
+ text: @message,
69
+ collapsible: true,
70
+ title: {
71
+ text: 'Deployment Status'
72
+ },
73
+ description: {
74
+ text: @message
75
+ },
76
+ details: [
77
+ {
78
+ lozenge: {
79
+ text: @status_text,
80
+ appearance: @status
119
81
  }
120
- ]
121
- }
122
- ]
123
-
82
+ }
83
+ ]
84
+ }
124
85
  }
125
86
  ]
126
87
  }
127
88
  }
128
-
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)
139
89
  end
140
-
141
- before "deploy:updated", "stride:notify_deploy_started"
142
- after "deploy:finished", "stride:notify_deploy_finished"
143
- before "deploy:reverted", "stride:notify_deploy_failed"
144
90
  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.2.1
4
+ version: 0.3.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-23 00:00:00.000000000 Z
11
+ date: 2018-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano