capistrano-sentry 0.3.0 → 0.4.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
  SHA256:
3
- metadata.gz: eb193cb50eb3f8ecfd39146451c570de4536f8ff22a86aef6663bdd290db0814
4
- data.tar.gz: 34316e7f275118450ae34fd9722b6d2f050f0849bb92cec062816bcc0e0c74e4
3
+ metadata.gz: 68fd747d897527e62a5ac086ebc361a5c4b166c059d7c3596b85f7b2a776374f
4
+ data.tar.gz: ce63a3acb315cc6b3c96fc01a968032e8a98d4ea080d21eedfe3bc17cb42a3c2
5
5
  SHA512:
6
- metadata.gz: daedfea3dfadbb1b6395bf73c0f4f4b11a3a417c33d77e30e79f0bb7034d010c027a1f0126e4161a355dc3e4475f64f7313606a33408b84706cad1a76eae3de3
7
- data.tar.gz: 016b032dc21bc1276389eb3dfda706246d09106da1913d5384980ecf245c41184132ba09e31d6855822e59650c9789dddea62f29afd845341bca7b8dd7335768
6
+ metadata.gz: 9b3ccae3566b22f9fa686821dae840b0ddd63aa49f9dea6a3d1eaad27802ad33933f650be0706f8ad4c2cf3f10f53035a263a859385577263ff0b6a5d338a826
7
+ data.tar.gz: 5e85c1e6d80eaa6dcf43af44ec0e70f76f3de0d31028b0481ea22922501ca73ae350bfda417d1b8af152c7999398911331ad73703fb55f59cbb012af776e198f
data/README.md CHANGED
@@ -56,6 +56,14 @@ after 'deploy:published', 'sentry:notice_deployment'
56
56
 
57
57
  * `sentry_repo`: The `repository` name to be used when reporting repository details to Sentry [computed from `fetch(:repo_url)` by default -- `https://github.com/codeur/capistrano-sentry` becomes `//github.com/codeur/capistrano-sentry` and `git@github.com:codeur/capistrano-sentry.git` becomes `codeur/capistrano-sentry`]
58
58
 
59
+ * `sentry_repo_integration`: this enables/disables submission of git repo information (`release_refs` below) to Sentry [Enabled (`true`) by default].
60
+
61
+ * `sentry_release_refs`: Repository details about this realease (`repository`, `commit`, `previousCommit`) to Sentry [computed from `sentry_repo`, `current_revision`, and `previous_revision`)].
62
+
63
+ * `sentry_release_version`: Version number (tag, etc.) used to identify this release to Sentry [computed from `current_revision` or repository `HEAD`)].
64
+
65
+ * `deploy_name`: A name (revision, version number, tag, etc.) used to identify this release deploy to Sentry [computed from `sentry_release_version`+`fetch(:release_timestamp)`)].
66
+
59
67
  ### Sentry API Documentation
60
68
  * [Project Releases](https://docs.sentry.io/api/releases/post-project-releases/)
61
69
  * [Release Deploys](https://docs.sentry.io/api/releases/post-release-deploys/)
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.version = Capistrano::Sentry::VERSION
8
8
  spec.authors = ['Brice Texier']
9
9
  spec.email = ['brice@codeur.com']
10
-
10
+ spec.description = 'Sentry release/deployment integration'
11
11
  spec.summary = 'Sentry release/deployment integration'
12
12
  spec.homepage = 'https://github.com/codeur/capistrano-sentry'
13
13
  spec.license = 'MIT'
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Sentry
3
- VERSION = '0.3.0'.freeze
3
+ VERSION = '0.4.0'.freeze
4
4
  end
5
5
  end
@@ -33,14 +33,22 @@ namespace :sentry do
33
33
  require 'net/https'
34
34
  require 'json'
35
35
 
36
- version = `git rev-parse HEAD`.strip
36
+ head_revision = fetch(:current_revision) || `git rev-parse HEAD`.strip
37
+ prev_revision = fetch(:previous_revision) || `git rev-parse #{fetch(:current_revision)}^`.strip
37
38
 
38
39
  sentry_host = ENV['SENTRY_HOST'] || fetch(:sentry_host, 'https://sentry.io')
39
- orga_slug = fetch(:sentry_organization) || fetch(:application)
40
+ organization_slug = fetch(:sentry_organization) || fetch(:application)
40
41
  project = fetch(:sentry_project) || fetch(:application)
41
42
  environment = fetch(:stage) || 'default'
42
43
  api_token = ENV['SENTRY_API_TOKEN'] || fetch(:sentry_api_token)
43
- repo_name = fetch(:sentry_repo) || fetch(:repo_url).split(':').last.gsub(/\.git$/, '')
44
+ repo_integration_enabled = fetch(:sentry_repo_integration, true)
45
+ release_refs = fetch(:sentry_release_refs, [{
46
+ repository: fetch(:sentry_repo) || fetch(:repo_url).split(':').last.gsub(/\.git$/, ''),
47
+ commit: head_revision,
48
+ previousCommit: prev_revision,
49
+ }])
50
+ release_version = fetch(:sentry_release_version) || head_revision
51
+ deploy_name = fetch(:sentry_deploy_name) || "#{release_version}-#{fetch(:release_timestamp)}"
44
52
 
45
53
  uri = URI.parse(sentry_host)
46
54
  http = Net::HTTP.new(uri.host, uri.port)
@@ -48,29 +56,27 @@ namespace :sentry do
48
56
 
49
57
  headers = {
50
58
  'Content-Type' => 'application/json',
51
- 'Authorization' => 'Bearer ' + api_token.to_s
59
+ 'Authorization' => 'Bearer ' + api_token.to_s,
52
60
  }
53
61
 
54
- req = Net::HTTP::Post.new("/api/0/organizations/#{orga_slug}/releases/", headers)
55
- req.body = JSON.generate(
56
- version: version,
57
- refs: [{
58
- repository: repo_name,
59
- commit: fetch(:current_revision) || `git rev-parse HEAD`.strip
60
- }],
61
- projects: [project]
62
- )
62
+ req = Net::HTTP::Post.new("/api/0/organizations/#{organization_slug}/releases/", headers)
63
+ body = {
64
+ version: release_version,
65
+ projects: [project],
66
+ }
67
+ body[:refs] = release_refs if repo_integration_enabled
68
+ req.body = JSON.generate(body)
63
69
  response = http.request(req)
64
70
  if response.is_a? Net::HTTPSuccess
65
- info 'Uploaded release infos to Sentry'
66
- req = Net::HTTP::Post.new("/api/0/organizations/#{orga_slug}/releases/#{version}/deploys/", headers)
71
+ info "Notified Sentry of new release: #{release_version}"
72
+ req = Net::HTTP::Post.new("/api/0/organizations/#{organization_slug}/releases/#{release_version}/deploys/", headers)
67
73
  req.body = JSON.generate(
68
74
  environment: environment,
69
- name: "#{version}-#{fetch(:release_timestamp)}"
75
+ name: deploy_name,
70
76
  )
71
77
  response = http.request(req)
72
78
  if response.is_a? Net::HTTPSuccess
73
- info 'Uploaded deployment infos to Sentry'
79
+ info "Notified Sentry of new deployment: #{deploy_name}"
74
80
  else
75
81
  warn "Cannot notify sentry for new deployment. Response: #{response.code.inspect}: #{response.body}"
76
82
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-sentry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brice Texier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-02 00:00:00.000000000 Z
11
+ date: 2019-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -66,7 +66,7 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '10.0'
69
- description:
69
+ description: Sentry release/deployment integration
70
70
  email:
71
71
  - brice@codeur.com
72
72
  executables: []