We have a server running a laravel app. It receives deploys through envoyer.io, and using the deployment hooks, on each deploy we generate a new release and a new deploy attached to it.
We do it by using curl as follows:
export SENTRY_BEARER_TOKEN="{{sentry's bearer token here}}"
export SENTRY_PROJECT="{{projectName}}"
export ENVIRONMENT="develop"
export PREVIOUS_SHA=`tail {{release}}/.commit_hash_previous`
cd {{ release }}
curl https://sentry.io/api/0/organizations/{{organization}}/releases/ \
-H "Authorization: Bearer ${SENTRY_BEARER_TOKEN}" \
-X POST \
-H "Content-Type:application/json" \
-d "{
\"environment\":\"${ENVIRONMENT}\",
\"version\":\"{{sha}}\",
\"refs\":[{
\"repository\":\"{{repository_name}}\",
\"commit\":\"{{sha}}\",
\"previousCommit\": \"${PREVIOUS_SHA}\"
}],
\"projects\": [\"{{sentry_project_slug}}\"]
}"
curl https://sentry.io/api/0/organizations/{{organization}}/releases/{{sha}}/deploys/ \
-X POST \
-H "Authorization: Bearer ${SENTRY_BEARER_TOKEN}" \
-H 'Content-Type: application/json' \
-d "
{
\"environment\": \"${ENVIRONMENT}\",
\"name\": \"{{release}}\"
}"
The above code runs on each deployment to each environment (develop and production).
And so far, it seems to be working… I am getting the Releases tab populated, with releases that correspond to the sha of the commit that triggers each deployment… This is, pretty much, what we intended… However the distribution of commits to these releases/deploys does not seem to be correct.
We end up with something like this:
Looking like there are 90 or so commits on each deploy, which is strange, as a lot of these deploys (in the screenshot) were hotfixes on a file while I was tweaking the envoyer hooks for these things to get logged properly…
I managed to make it show the environment of the deployment, and the sha of the commit in the release, but the commits… I need help with that part… for I am totally lost.
Edit:
Forgot to add, our repository is on bitbucket. It is a private repo. We had it added in the organization settings. Is there anywhere else where one must add it!? If yes, then maybe I was missing that!? Although, the releases feature kinda behaves as though it has access to the repository … too much access even…