gitlab rest-api 如何将作业/管道链接到项目计划

时间:2021-06-22 14:50:25

标签: gitlab-api

大多数项目都有许多管道计划,我可以将作业链接到管道和项目,但不能链接到启动作业的管道计划。我正在尝试创建一个简单的状态墙,其中包含红色/绿色的作业,如果您按下它,您将重新运行计划。深受启发:https://github.com/jan-molak/jenkins-build-monitor-plugin

以下是项目的管道时间表:

    {
        "project_id": "1518",
        "schedules": [
            {
                "id": 411,
                "description": "qa-04 provision users for demo",
                "ref": "test1-20210318",
                "cron": "6 18 * * *",
                "cron_timezone": "Europe/Copenhagen",
                "next_run_at": "2021-06-22T16:10:00.000Z",
                "active": true,
                "created_at": "2020-10-28T08:06:49.012Z",
                "updated_at": "2021-06-21T16:10:10.107Z",
                "owner": {..}
            },
            {
                "id": 410,
                "description": "test12 Demo fido2 solution fullstack test",
                "ref": "master",
                "cron": "40 06 * * *",
                "cron_timezone": "Europe/Copenhagen",
                "next_run_at": "2021-06-23T04:45:00.000Z",
                "active": true,
                "created_at": "2020-10-27T14:32:07.156Z",
                "updated_at": "2021-06-22T04:45:29.164Z",
                "owner": {..}
            },
            {
                "id": 409,
                "description": "test1 Demo fido2 solution fullstack test",
                "ref": "master",
                "cron": "05 04 * * *",
                "cron_timezone": "Europe/Copenhagen",
                "next_run_at": "2021-06-23T02:10:00.000Z",
                "active": true,
                "created_at": "2020-10-27T13:36:09.062Z",
                "updated_at": "2021-06-22T02:10:34.070Z",
                "owner": {..}
            }
        ]
    }

这是由管道执行的作业,但不是由哪个 schedule_id 执行的:

        "project_id": "1518",
        "jobs": [
            {
                "id": 3549568,
                "status": "failed",
                "stage": "test",
                "name": "test12",
                "ref": "master",
                "tag": false,
                "coverage": null,
                "allow_failure": false,
                "created_at": "2021-06-22T04:45:31.465Z",
                "started_at": "2021-06-22T04:45:33.354Z",
                "finished_at": "2021-06-22T05:00:03.734Z",
                "duration": 870.37944,
                "queued_duration": 1.029369,
                "user": {..},
                "commit": {..},
                "pipeline": {
                    "id": 489545,
                    "project_id": 1518,
                    "sha": "673073d3987fea3bb30a9433e15612712795c2cb",
                    "ref": "master",
                    "status": "failed",
                    "created_at": "2021-06-22T04:45:31.360Z",
                    "updated_at": "2021-06-22T05:00:03.874Z",
                    "web_url": "<url>/demo/demo-fullstack-test/-/pipelines/489545"
                },
                "web_url": "..",
                "artifacts_file": {..},
                "artifacts": [..],
                "runner": {..},
                "artifacts_expire_at": "2021-06-29T05:00:02.126Z",
                "tag_list": [ ]
            },

我可以尝试将调度程序描述与作业中的名称匹配,或者尝试使用可以匹配 crontab 的内容检查作业开始的_at。是否有任何其他 gitlab api 显示我可能已经监督过的这个映射。

0 个答案:

没有答案