正式なドキュメントは英語版であり、この日本語訳はAI支援翻訳により作成された参考用のものです。日本語訳の一部の内容は人間によるレビューがまだ行われていないため、翻訳のタイミングにより英語版との間に差異が生じることがあります。最新かつ正確な情報については、英語版をご参照ください。
ドキュメントに関する現在のご利用体験についてお聞かせください。アンケートにご協力ください。

パイプラインスケジュールAPI

  • プラン: Free、Premium、Ultimate
  • 提供形態: GitLab.com、GitLab Self-Managed、GitLab Dedicated

このAPIを使用して、パイプラインスケジュールを操作します。

すべてのパイプラインスケジュールを一覧表示する

プロジェクトのすべてのパイプラインスケジュールを一覧表示します。

GET /projects/:id/pipeline_schedules
属性型必須説明
id整数または文字列はいプロジェクトのIDまたはURLエンコードされたパス。
scope文字列いいえパイプラインスケジュールのスコープ。次のいずれかである必要があります: active, inactive。
shell
curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/29/pipeline_schedules"
json
[
    {
        "id": 13,
        "description": "Test schedule pipeline",
        "ref": "refs/heads/main",
        "cron": "* * * * *",
        "cron_timezone": "Asia/Tokyo",
        "next_run_at": "2017-05-19T13:41:00.000Z",
        "active": true,
        "created_at": "2017-05-19T13:31:08.849Z",
        "updated_at": "2017-05-19T13:40:17.727Z",
        "owner": {
            "name": "Administrator",
            "username": "root",
            "id": 1,
            "state": "active",
            "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
            "web_url": "https://gitlab.example.com/root"
        },
        "inputs": [
            {
                "name": "deploy_strategy",
                "value": "blue-green"
            },
            {
                "name": "feature_flags",
                "value": ["flag1", "flag2"]
            }
        ]
    }
]

inputsフィールドは、メンテナーまたはオーナーロールを持つユーザー、またはスケジュールオーナーの応答にのみ含まれます。

パイプラインスケジュールを取得する

プロジェクトのパイプラインスケジュールを取得します。

GET /projects/:id/pipeline_schedules/:pipeline_schedule_id
属性型必須説明
id整数または文字列はいプロジェクトのIDまたはURLエンコードされたパス。
pipeline_schedule_id整数はいパイプラインスケジュールのID。
shell
curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13"
json
{
    "id": 13,
    "description": "Test schedule pipeline",
    "ref": "refs/heads/main",
    "cron": "* * * * *",
    "cron_timezone": "Asia/Tokyo",
    "next_run_at": "2017-05-19T13:41:00.000Z",
    "active": true,
    "created_at": "2017-05-19T13:31:08.849Z",
    "updated_at": "2017-05-19T13:40:17.727Z",
    "last_pipeline": {
        "id": 332,
        "sha": "0e788619d0b5ec17388dffb973ecd505946156db",
        "ref": "refs/heads/main",
        "status": "pending"
    },
    "owner": {
        "name": "Administrator",
        "username": "root",
        "id": 1,
        "state": "active",
        "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
        "web_url": "https://gitlab.example.com/root"
    },
    "variables": [
        {
            "key": "TEST_VARIABLE_1",
            "variable_type": "env_var",
            "value": "TEST_1",
            "raw": false
        }
    ],
    "inputs": [
        {
            "name": "deploy_strategy",
            "value": "blue-green"
        },
        {
            "name": "feature_flags",
            "value": ["flag1", "flag2"]
        }
    ]
}

inputsおよびvariablesフィールドは、メンテナーまたはオーナーロールを持つユーザー、またはスケジュールオーナーの応答にのみ含まれます。

パイプラインスケジュールによってトリガーされたすべてのパイプラインを一覧表示する

プロジェクト内のパイプラインスケジュールによってトリガーされたすべてのパイプラインを一覧表示します。

GET /projects/:id/pipeline_schedules/:pipeline_schedule_id/pipelines

サポートされている属性は以下のとおりです:

属性型必須説明
id整数または文字列はいプロジェクトのIDまたはURLエンコードされたパス。
pipeline_schedule_id整数はいパイプラインスケジュールのID。
scope文字列いいえパイプラインのスコープ。次のいずれか: running, pending, finished, branches, tags。
sort文字列いいえパイプラインをascまたはdescの順にソートします。デフォルトはascです。
status文字列いいえパイプラインのステータス。次のいずれか: created, waiting_for_resource, preparing, pending, running, success, failed, canceled, skipped, manual, scheduled。
updated_after日時いいえ指定された日付より後に更新されたパイプラインを返します。ISO 8601形式(2019-03-15T08:00:00Z)で指定します。
updated_before日時いいえ指定された日付より前に更新されたパイプラインを返します。ISO 8601形式(2019-03-15T08:00:00Z)で指定します。
created_after日時いいえ指定された日付より後に作成されたパイプラインを返します。ISO 8601形式(2019-03-15T08:00:00Z)で指定します。
created_before日時いいえ指定された日付より前に作成されたパイプラインを返します。ISO 8601形式(2019-03-15T08:00:00Z)で指定します。

リクエスト例:

shell
curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13/pipelines"

レスポンス例:

json
[
  {
    "id": 47,
    "iid": 12,
    "project_id": 29,
    "status": "pending",
    "source": "scheduled",
    "ref": "new-pipeline",
    "sha": "a91957a858320c0e17f3a0eca7cfacbff50ea29a",
    "web_url": "https://example.com/foo/bar/pipelines/47",
    "created_at": "2016-08-11T11:28:34.085Z",
    "updated_at": "2016-08-11T11:32:35.169Z"
  },
  {
    "id": 48,
    "iid": 13,
    "project_id": 29,
    "status": "pending",
    "source": "scheduled",
    "ref": "new-pipeline",
    "sha": "eb94b618fb5865b26e80fdd8ae531b7a63ad851a",
    "web_url": "https://example.com/foo/bar/pipelines/48",
    "created_at": "2016-08-12T10:06:04.561Z",
    "updated_at": "2016-08-12T10:09:56.223Z"
  }
]

新しいパイプラインスケジュールを作成する

プロジェクトの新しいパイプラインスケジュールを作成します。

POST /projects/:id/pipeline_schedules
属性型必須説明
cron文字列はいCronスケジュール。例: 0 1 * * *。
description文字列はいパイプラインスケジュールの説明。
id整数または文字列はいプロジェクトのIDまたはURLエンコードされたパス。
ref文字列はいパイプラインをトリガーするブランチまたはタグ名。短いrefs (main) または完全なrefs (refs/heads/mainまたはrefs/tags/main) のいずれかを受け入れます。値がブランチまたはタグのいずれかに一致しない限り、短いrefsは自動的に完全なrefsに展開されます。
activeブール値いいえパイプラインスケジュールを有効にします。falseが設定されている場合、パイプラインスケジュールは初期状態では非アクティブになります (デフォルト: true)。
cron_timezone文字列いいえActiveSupport::TimeZoneがサポートするタイムゾーン。例: Pacific Time (US & Canada) (デフォルト: UTC)。
inputsハッシュいいえパイプラインスケジュールに渡す入力の配列。各入力にはnameとvalueが含まれます。値には文字列、配列、数値、ブール値を使用できます。

リクエスト例:

shell
curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/29/pipeline_schedules" \
  --form "description=Build packages" \
  --form "ref=main" \
  --form "cron=0 1 * * 5" \
  --form "cron_timezone=UTC" \
  --form "active=true"

レスポンス例:

json
{
    "id": 14,
    "description": "Build packages",
    "ref": "refs/heads/main",
    "cron": "0 1 * * 5",
    "cron_timezone": "UTC",
    "next_run_at": "2017-05-26T01:00:00.000Z",
    "active": true,
    "created_at": "2017-05-19T13:43:08.169Z",
    "updated_at": "2017-05-19T13:43:08.169Z",
    "last_pipeline": null,
    "owner": {
        "name": "Administrator",
        "username": "root",
        "id": 1,
        "state": "active",
        "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
        "web_url": "https://gitlab.example.com/root"
    }
}

inputsを含むリクエストの例:

shell
curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/29/pipeline_schedules" \
  --form "description=Build packages" \
  --form "ref=main" \
  --form "cron=0 1 * * 5" \
  --form "cron_timezone=UTC" \
  --form "active=true" \
  --form "inputs[][name]=deploy_strategy" \
  --form "inputs[][value]=blue-green"

パイプラインスケジュールを更新する

プロジェクトのパイプラインスケジュールを更新します。更新が完了すると、自動的に再スケジュールされます。

PUT /projects/:id/pipeline_schedules/:pipeline_schedule_id
属性型必須説明
id整数または文字列はいプロジェクトのIDまたはURLエンコードされたパス。
pipeline_schedule_id整数はいパイプラインスケジュールのID。
activeブール値いいえパイプラインスケジュールを有効にします。falseが設定されている場合、パイプラインスケジュールは初期状態では非アクティブになります。
cron_timezone文字列いいえActiveSupport::TimeZone (例: Pacific Time (US & Canada)) またはTZInfo::Timezone (例: America/Los_Angeles) でサポートされているタイムゾーン。
cron文字列いいえCronスケジュール。例: 0 1 * * *。
description文字列いいえパイプラインスケジュールの説明。
ref文字列いいえパイプラインをトリガーするブランチまたはタグ名。短いrefs (main) または完全なrefs (refs/heads/mainまたはrefs/tags/main) のいずれかを受け入れます。値がブランチまたはタグのいずれかに一致しない限り、短いrefsは自動的に完全なrefsに展開されます。
inputsハッシュいいえパイプラインスケジュールに渡す入力の配列。各入力にはnameとvalueが含まれます。既存の入力を削除するには、nameフィールドを含め、