Skip to content

Commit 97cdcbc

Browse files
Add trigger configuration support to Bitbucket pipelines config
1 parent 489e06c commit 97cdcbc

4 files changed

Lines changed: 54 additions & 4 deletions

File tree

src/usethis/_integrations/ci/bitbucket/schema.py

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: schema.json
3-
# timestamp: 2025-10-26T23:11:28+00:00
3+
# timestamp: 2025-11-12T19:13:24+00:00
44
# using the command:
55
# datamodel-codegen --input tests\usethis\_integrations\ci\bitbucket\schema.json --input-file-type jsonschema --output src\usethis\_integrations\ci\bitbucket\schema.py --enum-field-as-literal all --field-constraints --use-double-quotes --use-union-operator --use-standard-collections --use-default-kwarg --extra-fields=allow --output-model-type pydantic_v2.BaseModel --target-python-version 3.10
66
# ruff: noqa: ERA001
@@ -160,6 +160,24 @@ class ImportPipeline(BaseModel):
160160
)
161161

162162

163+
class TriggerConfiguration(BaseModel):
164+
model_config = ConfigDict(
165+
extra="allow",
166+
)
167+
condition: str = Field(
168+
...,
169+
description="Boolean expression that determines whether the trigger should execute.",
170+
examples=['BITBUCKET_BRANCH == "main"'],
171+
title="Trigger Condition",
172+
)
173+
pipelines: list[str] = Field(
174+
...,
175+
description="List of pipeline names to trigger when the condition is met. Can reference pipelines from the custom section.",
176+
min_length=1,
177+
title="Pipeline Names",
178+
)
179+
180+
163181
class ImageBase(BaseModel):
164182
model_config = ConfigDict(
165183
extra="allow",
@@ -308,6 +326,15 @@ class Runtime(BaseModel):
308326
cloud: Cloud | None = None
309327

310328

329+
class TriggerConfigurationList(RootModel[list[TriggerConfiguration]]):
330+
root: list[TriggerConfiguration] = Field(
331+
...,
332+
description="List of trigger configurations for a specific trigger type.",
333+
min_length=1,
334+
title="Trigger Configuration List",
335+
)
336+
337+
311338
class CacheExpanded(BaseModel):
312339
model_config = ConfigDict(
313340
extra="allow",
@@ -738,6 +765,27 @@ class PipelinesConfiguration(BaseModel):
738765
title="Global Options",
739766
)
740767
pipelines: Pipelines | None = Field(default=None, title="Pipelines")
768+
triggers: dict[str, TriggerConfigurationList] | None = Field(
769+
default=None,
770+
description="Event-based triggers that automatically run pipelines when specific events occur. The property names represent trigger types (e.g., repository-push, pullrequest-push).",
771+
examples=[
772+
{
773+
"pullrequest-push": [
774+
{
775+
"condition": 'BITBUCKET_PR_DESTINATION_BRANCH == "main"',
776+
"pipelines": ["pipeline2"],
777+
}
778+
],
779+
"repository-push": [
780+
{
781+
"condition": 'BITBUCKET_BRANCH == "main"',
782+
"pipelines": ["pipeline1"],
783+
}
784+
],
785+
}
786+
],
787+
title="Pipeline Triggers",
788+
)
741789

742790

743791
class Model(RootModel[PipelinesConfiguration]):

0 commit comments

Comments
 (0)