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

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

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

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

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

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

GET /projects/:id/pipeline_schedules
属性必須説明
id整数または文字列はいプロジェクトのIDまたはURLエンコードされたパス
scope文字列いいえパイプラインスケジュールのスコープ。次のいずれかである必要があります: active, inactive
curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/29/pipeline_schedules"
[
    {
        "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。
curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13"
{
    "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)で指定します。

リクエスト例:

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

レスポンス例:

[
  {
    "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ハッシュいいえパイプラインスケジュールに渡す入力の配列。各入力にはnamevalueが含まれます。値には文字列、配列、数値、ブール値を使用できます。

リクエスト例:

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"

レスポンス例:

{
    "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を含むリクエストの例:

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ハッシュいいえパイプラインスケジュールに渡す入力の配列。各入力にはnamevalueが含まれます。既存の入力を削除するには、nameフィールドを含め、destroytrueに設定します。値には文字列、配列、数値、ブール値を使用できます。

リクエスト例:

curl --request PUT \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13" \
  --form "cron=0 2 * * *"

レスポンス例:

{
    "id": 13,
    "description": "Test schedule pipeline",
    "ref": "refs/heads/main",
    "cron": "0 2 * * *",
    "cron_timezone": "Asia/Tokyo",
    "next_run_at": "2017-05-19T17:00:00.000Z",
    "active": true,
    "created_at": "2017-05-19T13:31:08.849Z",
    "updated_at": "2017-05-19T13:44:16.135Z",
    "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"
    }
}

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

curl --request PUT \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13" \
  --form "cron=0 2 * * *" \
  --form "inputs[][name]=deploy_strategy" \
  --form "inputs[][value]=rolling" \
  --form "inputs[][name]=existing_input" \
  --form "inputs[][destroy]=true"

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

プロジェクトのパイプラインスケジュールのオーナーを更新します。

POST /projects/:id/pipeline_schedules/:pipeline_schedule_id/take_ownership
属性必須説明
id整数または文字列はいプロジェクトのIDまたはURLエンコードされたパス
pipeline_schedule_id整数はいパイプラインスケジュールのID。
curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13/take_ownership"
{
    "id": 13,
    "description": "Test schedule pipeline",
    "ref": "refs/heads/main",
    "cron": "0 2 * * *",
    "cron_timezone": "Asia/Tokyo",
    "next_run_at": "2017-05-19T17:00:00.000Z",
    "active": true,
    "created_at": "2017-05-19T13:31:08.849Z",
    "updated_at": "2017-05-19T13:46:37.468Z",
    "last_pipeline": {
        "id": 332,
        "sha": "0e788619d0b5ec17388dffb973ecd505946156db",
        "ref": "refs/heads/main",
        "status": "pending"
    },
    "owner": {
        "name": "shinya",
        "username": "maeda",
        "id": 50,
        "state": "active",
        "avatar_url": "http://www.gravatar.com/avatar/8ca0a796a679c292e3a11da50f99e801?s=80&d=identicon",
        "web_url": "https://gitlab.example.com/maeda"
    }
}

パイプラインスケジュールを削除する

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

DELETE /projects/:id/pipeline_schedules/:pipeline_schedule_id
属性必須説明
id整数または文字列はいプロジェクトのIDまたはURLエンコードされたパス
pipeline_schedule_id整数はいパイプラインスケジュールのID。
curl --request DELETE \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13"
{
    "id": 13,
    "description": "Test schedule pipeline",
    "ref": "refs/heads/main",
    "cron": "0 2 * * *",
    "cron_timezone": "Asia/Tokyo",
    "next_run_at": "2017-05-19T17:00:00.000Z",
    "active": true,
    "created_at": "2017-05-19T13:31:08.849Z",
    "updated_at": "2017-05-19T13:46:37.468Z",
    "last_pipeline": {
        "id": 332,
        "sha": "0e788619d0b5ec17388dffb973ecd505946156db",
        "ref": "refs/heads/main",
        "status": "pending"
    },
    "owner": {
        "name": "shinya",
        "username": "maeda",
        "id": 50,
        "state": "active",
        "avatar_url": "http://www.gravatar.com/avatar/8ca0a796a679c292e3a11da50f99e801?s=80&d=identicon",
        "web_url": "https://gitlab.example.com/maeda"
    }
}

パイプラインスケジュールをすぐに実行する

パイプラインスケジュールをすぐに実行します。このパイプラインの次回のスケジュール実行には影響しません。

POST /projects/:id/pipeline_schedules/:pipeline_schedule_id/play
属性必須説明
id整数または文字列はいプロジェクトのIDまたはURLエンコードされたパス
pipeline_schedule_id整数はいパイプラインスケジュールのID。

リクエスト例:

curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/42/pipeline_schedules/1/play"

レスポンス例:

{
  "message": "201 Created"
}

パイプラインスケジュールの変数を作成する

パイプラインスケジュールの新しい変数を作成します。

POST /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables
属性必須説明
id整数または文字列はいプロジェクトのIDまたはURLエンコードされたパス
key文字列はい変数のキー。255文字以下である必要があり、A-Za-z0-9、および_のみが許可されます。
pipeline_schedule_id整数はいパイプラインスケジュールのID。
value文字列はい変数の値。
variable_type文字列いいえ変数のタイプ。利用可能なタイプは: env_var (デフォルト) とfile
curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13/variables" \
  --form "key=NEW_VARIABLE" \
  --form "value=new value"
{
    "key": "NEW_VARIABLE",
    "variable_type": "env_var",
    "value": "new value"
}

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

パイプラインスケジュールの変数を取得します。

GET /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables/:key
属性必須説明
id整数または文字列はいプロジェクトのIDまたはURLエンコードされたパス
key文字列はい変数のキー。
pipeline_schedule_id整数はいパイプラインスケジュールのID。

成功した場合、200 OKと次のレスポンス属性を返します:

属性説明
key文字列その変数のキー。
value文字列変数の値。
variable_type文字列変数の型。env_varまたはfileのいずれか。

リクエスト例:

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

レスポンス例:

{
    "key": "NEW_VARIABLE",
    "variable_type": "env_var",
    "value": "new value"
}

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

パイプラインスケジュールの変数を更新します。

PUT /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables/:key
属性必須説明
id整数または文字列はいプロジェクトのIDまたはURLエンコードされたパス
key文字列はい変数のキー。
pipeline_schedule_id整数はいパイプラインスケジュールのID。
value文字列はい変数の値。
variable_type文字列いいえ変数のタイプ。利用可能なタイプは: env_var (デフォルト) とfile
curl --request PUT \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13/variables/NEW_VARIABLE" \
  --form "value=updated value"
{
    "key": "NEW_VARIABLE",
    "value": "updated value",
    "variable_type": "env_var"
}

パイプラインスケジュールの変数を削除する

パイプラインスケジュールの変数を削除します。

DELETE /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables/:key
属性必須説明
id整数または文字列はいプロジェクトのIDまたはURLエンコードされたパス
key文字列はい変数のキー。
pipeline_schedule_id整数はいパイプラインスケジュールのID。
curl --request DELETE \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/29/pipeline_schedules/13/variables/NEW_VARIABLE"
{
    "key": "NEW_VARIABLE",
    "value": "updated value"
}

あいまいなrefs

APIは、短いrefを完全なrefに自動的に展開できません。次の場合です:

  • 短いrefと同じ名前のブランチとタグの両方が存在する場合。
  • その名前のブランチまたはタグが存在しない場合。

この問題を解決するには、完全なrefを指定して、正しいリソースが識別されるようにします。