Loading
Add event timestamp to deployments webhooks
What does this MR do?
See #264393 (closed)
We want to allow users to understand when deployment status transition happened, so this MR captures Time.current and passes it to json payload.
Original implementation is taken from #264393 (comment 477948829)
The alternative is to add created_at to deployment json, and deployable which has started_at/finished_at.
Some arguments against this approach:
- It's hard to know which attribute to track if the attribute in interest is changed per deployment status. e.g. When the hook receiver should look at
deployment.deployable.started_atand when it should look atdeployment.finished_atdeployablehas a lot of attributes and associations, we would want to carefully look at what can be exposed in cheap operation.deployabledoesn't exist for deployments created via API i.e. external CD system integration. Hence this approach works for internal CD only.
from this comment
Screenshots (strongly suggested)
{"object_kind":"deployment","status":"success","status_changed_at":"2021-04-28 21:50:00 +0200","deployable_id":857,"deployable_url":"http://10.126.0.2:3000/root/deployment-webhooks-2/-/jobs/857","environment":"staging","project":{"id":37,"name":"deployment-webhooks-2","description":"","web_url":"http://10.126.0.2:3000/root/deployment-webhooks-2","avatar_url":null,"git_ssh_url":"ssh://vlad@10.126.0.2:2222/root/deployment-webhooks-2.git","git_http_url":"http://10.126.0.2:3000/root/deployment-webhooks-2.git","namespace":"Administrator","visibility_level":0,"path_with_namespace":"root/deployment-webhooks-2","default_branch":"master","ci_config_path":null,"homepage":"http://10.126.0.2:3000/root/deployment-webhooks-2","url":"ssh://vlad@10.126.0.2:2222/root/deployment-webhooks-2.git","ssh_url":"ssh://vlad@10.126.0.2:2222/root/deployment-webhooks-2.git","http_url":"http://10.126.0.2:3000/root/deployment-webhooks-2.git"},"short_sha":"5eb17436","user":{"id":1,"name":"Administrator","username":"root","avatar_url":"https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon","email":"admin@example.com"},"user_url":"http://10.126.0.2:3000/root","commit_url":"http://10.126.0.2:3000/root/deployment-webhooks-2/-/commit/5eb1743636f3d1b201ca097d24d69d9b2471db6d","commit_title":"Update .gitlab-ci.yml"}Does this MR meet the acceptance criteria?
Conformity
📋 Does this MR need a changelog?- I have included a changelog entry.
- I have not included a changelog entry because _____.
- Documentation (if required)
- Code review guidelines
- Merge request performance guidelines
- Style guides
- Database guides
- Separation of EE specific content
Availability and Testing
- Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process.
- Tested in all supported browsers
- Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- Label as security and @ mention
@gitlab-com/gl-security/appsec - The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- Security reports checked/validated by a reviewer from the AppSec team
Related to #264393 (closed)
Edited by Etienne Baqué