Sentry Commit Tracking

Reading time ~1 minute

https://docs.sentry.io/workflow/integrations/global-integrations/#commit-tracking-4

关于 Releases

https://docs.sentry.io/workflow/releases/?platform=php#create-deploy

如果配置了releases版本, 会有额外的功能

配置发布版本

  1. 在项目sdk配置
  2. 在sentry上创建 releases 版本, 关联 commits
  3. 部署是通知 sentry

ruby sdk release 配置

Create Release and Associate Commits

这一步告诉sentry 这个release 有哪些commit

有两步

  • Organization Settings > Integrations. 配置 gitab 集成
  • 部署的时候告诉sentry 部署了啥, 有哪些commit, 可以用 sentry-cli工具

在gitlab ci 的配置示例

官方 sentry-cli 文档 https://docs.sentry.io/workflow/releases/?platform=php#associate-commits-with-a-release

sentry_commmit_tracking:
  stage: after_deploy
  image: getsentry/sentry-cli
  dependencies:
    - staging_deploy
    - prod_deploy
  script:
    - echo "Sentry Commit Tracking"
    - export SENTRY_URL=https://sentry.shijiplus.com/
    - export SENTRY_AUTH_TOKEN=6db606dd59314e379f65c5d98751e365b6951f8bb79a40a48eda1e17710e4c0c
    - export SENTRY_ORG=sentry
    - export SENTRY_PROJECT=laiwang-backend
    - sentry-cli releases new $CI_COMMIT_SHA
    - sentry-cli releases set-commits --auto $CI_COMMIT_SHA
    - echo $CI_COMMIT_REF_NAME
    - if [[ "$CI_COMMIT_REF_NAME" == "devel" ]] ; then export RAILS_ENV=staging; else export RAILS_ENV=production; fi
    - sentry-cli releases deploys $CI_COMMIT_SHA new -e $RAILS_ENV
  only:
    - master
    - devel

也可以使用api的方式

# Create a new release
curl https://sentry.io/api/0/organizations/:organization_slug/releases/ \
  -X POST \
  -H 'Authorization: Bearer {TOKEN}' \
  -H 'Content-Type: application/json' \
  -d '
 {
 "version": "2da95dfb052f477380608d59d32b4ab9",
 "refs": [{
 "repository":"owner-name/repo-name",
 "commit":"2da95dfb052f477380608d59d32b4ab9",
 "previousCommit":"1e6223108647a7bfc040ef0ca5c92f68ff0dd993"
 }],
 "projects":["my-project","my-other-project"]
}

新版本创建部署提醒

comments powered by Disqus