harness / gitness

Gitness is an Open Source developer platform with Source Control management, Continuous Integration and Continuous Delivery.
https://gitness.com
Apache License 2.0
32.11k stars 2.8k forks source link

webhooks on build complete event #2921

Closed vyckou closed 4 years ago

vyckou commented 4 years ago

Hi,

In documentation it is stated , that webhooks are emitted on following events:

User is created
User is deleted
Repository is activated
Repository is de-activated
Build is created
Build is updated
Build is completed

ref: https://docs.drone.io/webhooks/examples/

while in the code https://github.com/drone/drone/blob/1ddf7963feb98ae7fed7dd2834389441f2401c77/core/webhook.go#L29 there is no such type as completed Any plans to update documentation or implement completed action?

ashwilliams1 commented 4 years ago

Build is completed

a webhook is emitted when a build is complete. the action type is updated and the build status will no longer be pending or running. this is how you know it is completed.

vyckou commented 4 years ago

Unfortunately that is not true: There is a webhook content, which arrived when pipeline run ended: All steps have status success, but build status is still running

{
    "event": "build",
    "action": "updated",
    "repo": {
        "id": 1625,
        "uid": "2639",
        "user_id": 6,
        "namespace": "DRON",
        "name": "app-cicd-test",
        "slug": "DRON/app-cicd-test",
        "scm": "",
        "git_http_url": "https://syst-stash.bitbucket.server.net/scm/dron/app-cicd-test.git",
        "git_ssh_url": "ssh://git@syst-stash.bitbucket.server.net:7999/dron/app-cicd-test.git",
        "link": "https://syst-stash.bitbucket.server.net/projects/DRON/repos/app-cicd-test/browse",
        "default_branch": "master",
        "private": true,
        "visibility": "private",
        "active": true,
        "config_path": ".drone.yml",
        "trusted": true,
        "protected": false,
        "ignore_forks": false,
        "ignore_pull_requests": false,
        "timeout": 60,
        "counter": 169,
        "synced": 1568632832,
        "created": 1568632832,
        "updated": 1573563025,
        "version": 173,
        "build": {
            "id": 1305,
            "repo_id": 1625,
            "trigger": "fila",
            "number": 169,
            "status": "running",
            "event": "push",
            "action": "",
            "link": "",
            "timestamp": 0,
            "message": "readme.md edited online with Bitbucket",
            "before": "",
            "after": "1abbca556daecc3dc61a63d111696ee85106d17b",
            "ref": "refs/heads/e-f-g-test",
            "source_repo": "",
            "source": "e-f-g-test",
            "target": "e-f-g-test",
            "author_login": "be1177",
            "author_name": "FirstName LastName",
            "author_email": "MIPR@domain.com",
            "author_avatar": "https://www.gravatar.com/avatar/37a8cfcacc.jpg",
            "sender": "fifi",
            "started": 1582198144,
            "finished": 0,
            "created": 1582198141,
            "updated": 1582198144,
            "version": 2,
            "stages": [
                {
                    "id": 1304,
                    "repo_id": 1625,
                    "build_id": 1305,
                    "number": 1,
                    "name": "testing",
                    "kind": "pipeline",
                    "type": "docker",
                    "status": "running",
                    "errignore": false,
                    "exit_code": 0,
                    "machine": "d6a86b9648e9",
                    "os": "linux",
                    "arch": "amd64",
                    "started": 1582198143,
                    "stopped": 0,
                    "created": 1582198141,
                    "updated": 1582198143,
                    "version": 3,
                    "on_success": true,
                    "on_failure": false,
                    "steps": [
                        {
                            "id": 4502,
                            "step_id": 1304,
                            "number": 1,
                            "name": "clone",
                            "status": "success",
                            "exit_code": 0,
                            "started": 1582198144,
                            "stopped": 1582198147,
                            "version": 3
                        },
                        {
                            "id": 4503,
                            "step_id": 1304,
                            "number": 2,
                            "name": "unittest_on_commit",
                            "status": "success",
                            "exit_code": 0,
                            "started": 1582198149,
                            "stopped": 1582198155,
                            "version": 3
                        },
                        {
                            "id": 4504,
                            "step_id": 1304,
                            "number": 3,
                            "name": "sonarqube_on_commit",
                            "status": "success",
                            "exit_code": 0,
                            "started": 1582198157,
                            "stopped": 1582198159,
                            "version": 3
                        },
                        {
                            "id": 4505,
                            "step_id": 1304,
                            "number": 4,
                            "name": "blackduck_on_commit",
                            "status": "success",
                            "exit_code": 0,
                            "started": 1582198160,
                            "stopped": 1582198162,
                            "version": 3
                        }
                    ]
                }
            ]
        }
    },
    "build": {
        "id": 1305,
        "repo_id": 1625,
        "trigger": "fila",
        "number": 169,
        "status": "running",
        "event": "push",
        "action": "",
        "link": "",
        "timestamp": 0,
        "message": "readme.md edited online with Bitbucket",
        "before": "",
        "after": "1abbca556daecc3dc61a63d111696ee85106d17b",
        "ref": "refs/heads/e-f-g-test",
        "source_repo": "",
        "source": "e-f-g-test",
        "target": "e-f-g-test",
        "author_login": "fifi",
        "author_name": "FirstName LastName",
        "author_email": "FILA@domain.com",
        "author_avatar": "https://www.gravatar.com/avatar/37a8cfcacc.jpg",
        "sender": "fifi",
        "started": 1582198144,
        "finished": 0,
        "created": 1582198141,
        "updated": 1582198144,
        "version": 2,
        "stages": [
            {
                "id": 1304,
                "repo_id": 1625,
                "build_id": 1305,
                "number": 1,
                "name": "testing",
                "kind": "pipeline",
                "type": "docker",
                "status": "running",
                "errignore": false,
                "exit_code": 0,
                "machine": "d6a86b9648e9",
                "os": "linux",
                "arch": "amd64",
                "started": 1582198143,
                "stopped": 0,
                "created": 1582198141,
                "updated": 1582198143,
                "version": 3,
                "on_success": true,
                "on_failure": false,
                "steps": [
                    {
                        "id": 4502,
                        "step_id": 1304,
                        "number": 1,
                        "name": "clone",
                        "status": "success",
                        "exit_code": 0,
                        "started": 1582198144,
                        "stopped": 1582198147,
                        "version": 3
                    },
                    {
                        "id": 4503,
                        "step_id": 1304,
                        "number": 2,
                        "name": "unittest_on_commit",
                        "status": "success",
                        "exit_code": 0,
                        "started": 1582198149,
                        "stopped": 1582198155,
                        "version": 3
                    },
                    {
                        "id": 4504,
                        "step_id": 1304,
                        "number": 3,
                        "name": "sonarqube_on_commit",
                        "status": "success",
                        "exit_code": 0,
                        "started": 1582198157,
                        "stopped": 1582198159,
                        "version": 3
                    },
                    {
                        "id": 4505,
                        "step_id": 1304,
                        "number": 4,
                        "name": "blackduck_on_commit",
                        "status": "success",
                        "exit_code": 0,
                        "started": 1582198160,
                        "stopped": 1582198162,
                        "version": 3
                    }
                ]
            }
        ]
    },
    "system": {
        "proto": "http",
        "host": "syst-drone.domain.net",
        "link": "http://syst-drone.domain.net",
        "version": "1.4.0"
    }
}

There is only way to determine, if the build has completed - is to iterate and check step status values

Also issue was about misleading documentation