Pipeline Webhook triggering twice with 'success' status

I’ve got a single webhook configured to receive pipeline events. I have a pipeline that builds, and then publishes to GitLab pages.

For every run of the pipeline, I receive two webhook triggers with a ‘success’ status. Once for the finishing of the build, and once for the finishing of the deploy to GitLab pages.

There doesn’t seem to be any way to differentiate these, so I know when the deploy is actually finished? The only difference in the content of the webhook body is the ‘finished_at’ time is later on the second ‘success’ event.

It feels like a bug to me, as it shouldn’t be firing with ‘success’ until the deploy is completed?

.gitlab-ci.yml:

image: node:12.16.1
# This folder is cached between builds
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
cache:
  paths:
    - node_modules/
pages:
  script:
    - yarn install
    - yarn build
  artifacts:
    paths:
      - public
  only:
    - master

deploy screen:

Note that the time it takes to deploy corresponds with the different ‘finished_at’ times in the webhook content below.

webhook ‘success’ event 1:

[
    {
        "object_kind": "pipeline",
        "object_attributes": {
            "id": 203438692,
            "ref": "master",
            "tag": false,
            "sha": "XXX",
            "before_sha": "0000000000000000000000000000000000000000",
            "source": "web",
            "status": "success",
            "detailed_status": "passed",
            "stages": [
                "test",
                "deploy"
            ],
            "created_at": "2020-10-16 08:07:55 UTC",
            "finished_at": "2020-10-16 08:09:22 UTC",
            "duration": 82,
            "variables": []
        },
        "merge_request": null,
        "user": { ... },
        "project": {
            "id": 17386209,
            "name": "XXX",
            "description": "",
            "web_url": "XXXi",
            "avatar_url": null,
            "git_ssh_url": "XXX",
            "git_http_url": "XXX",
            "namespace": "XXX",
            "visibility_level": 0,
            "path_with_namespace": "XXX",
            "default_branch": "master",
            "ci_config_path": null
        },
        "commit": {
            "id": "XXX",
            "message": "Add event logo to the API\n",
            "title": "Add event logo to the API",
            "timestamp": "2020-10-16T14:49:28+10:00",
            "url": "XXX",
            "author": {
                "name": "James Crowley",
                "email": "XXX"
            }
        },
        "builds": [
            {
                "id": 794535019,
                "stage": "test",
                "name": "pages",
                "status": "success",
                "created_at": "2020-10-16 08:07:55 UTC",
                "started_at": "2020-10-16 08:07:59 UTC",
                "finished_at": "2020-10-16 08:09:22 UTC",
                "when": "on_success",
                "manual": false,
                "allow_failure": false,
                "user": { ... },
                "runner": {
                    "id": 44028,
                    "description": "shared-runners-manager-3.gitlab.com",
                    "active": true,
                    "is_shared": true
                },
                "artifacts_file": {
                    "filename": "artifacts.zip",
                    "size": 5204717
                }
            }
        ]
    }
]

webhook success event 2:

[
    {
        "object_kind": "pipeline",
        "object_attributes": {
            "id": 203438692,
            "ref": "master",
            "tag": false,
            "sha": "XXX",
            "before_sha": "0000000000000000000000000000000000000000",
            "source": "web",
            "status": "success",
            "detailed_status": "passed",
            "stages": [
                "test",
                "deploy"
            ],
            "created_at": "2020-10-16 08:07:55 UTC",
            "finished_at": "2020-10-16 08:09:40 UTC",
            "duration": 82,
            "variables": []
        },
        "merge_request": null,
        "user": { ... },
        "project": {
            "id": 17386209,
            "name": "XXX",
            "description": "",
            "web_url": "XXX",
            "avatar_url": null,
            "git_ssh_url": "XXX",
            "git_http_url": "XXX",
            "namespace": "XXX",
            "visibility_level": 0,
            "path_with_namespace": "XXX",
            "default_branch": "master",
            "ci_config_path": null
        },
        "commit": {
            "id": "XXX",
            "message": "Add event logo to the API\n",
            "title": "Add event logo to the API",
            "timestamp": "2020-10-16T14:49:28+10:00",
            "url": "XXX",
            "author": {
                "name": "James Crowley",
                "email": "XXX"
            }
        },
        "builds": [
            {
                "id": 794535019,
                "stage": "test",
                "name": "pages",
                "status": "success",
                "created_at": "2020-10-16 08:07:55 UTC",
                "started_at": "2020-10-16 08:07:59 UTC",
                "finished_at": "2020-10-16 08:09:22 UTC",
                "when": "on_success",
                "manual": false,
                "allow_failure": false,
                "user": { ... },
                "runner": {
                    "id": 44028,
                    "description": "shared-runners-manager-3.gitlab.com",
                    "active": true,
                    "is_shared": true
                },
                "artifacts_file": {
                    "filename": "artifacts.zip",
                    "size": 5204717
                }
            }
        ]
    }
]

Heya, have you tried accessing /etc/gitlab/gitlab.rb and uncommenting: gitlab_rails['webhook_timeout'] , by default it’s set to 10 seconds.

Make sure to run sudo gitlab-ctl reconfigure after the changes.

When GitLab sends a webhook it expects a response in 10 seconds (set default value). If it does not receive one, it'll retry the webhook.
If the endpoint doesn't send its HTTP response within those 10 seconds, GitLab may decide the hook failed and retry it.
If you are receiving multiple requests, you can try increasing the default value to wait for the HTTP response after sending the webhook
by uncommenting or adding the following setting to your /etc/gitlab/gitlab.rb .

this is running on GitLab.com so I don’t have any access to that, unfortunately. And it’s very consistent in it’s behaviour having two different finished_at times, with the time apart being exactly the time it takes to run the deploy step to GitLab pages.