buildkite_sdk.sdk
1from .schema import ( 2 BlockStep as _block_step, 3 CommandStep as _command_step, 4 GroupStepClass as _group_step, 5 InputStep as _input_step, 6 TriggerStep as _trigger_step, 7 WaitStep as _wait_step, 8) 9from .block_step import BlockStepArgs 10from .command_step import CommandStepArgs 11from .group_step import GroupStepArgs 12from .input_step import InputStepArgs 13from .trigger_step import TriggerStepArgs 14from .wait_step import WaitStepArgs 15from .environment import Environment 16from .types import PipelineNotify 17from typing import Union 18import json 19import yaml 20 21 22class Pipeline: 23 """ 24 A pipeline. 25 """ 26 27 def __init__(self): 28 """A description of the constructor.""" 29 self.steps = [] 30 self.agents = None 31 self.env = None 32 self.notify = None 33 """I guess this is where we define the steps?""" 34 35 def add_agent(self, key: str, value: any): 36 if self.agents == None: 37 self.agents = {} 38 self.agents[key] = value 39 40 def add_environment_variable(self, key: str, value: any): 41 if self.env == None: 42 self.env = {} 43 self.env[key] = value 44 45 def add_notify(self, notify: PipelineNotify): 46 self.notify = notify 47 48 def add_step( 49 self, 50 props: Union[ 51 # classes 52 _block_step, 53 _command_step, 54 _group_step, 55 _input_step, 56 _trigger_step, 57 _wait_step, 58 # typed dicts 59 BlockStepArgs, 60 CommandStepArgs, 61 InputStepArgs, 62 GroupStepArgs, 63 TriggerStepArgs, 64 WaitStepArgs, 65 ], 66 ): 67 """Add a command step to the pipeline.""" 68 step = props 69 if isinstance( 70 props, 71 Union[ 72 _block_step, 73 _command_step, 74 _group_step, 75 _input_step, 76 _trigger_step, 77 _wait_step, 78 ], 79 ): 80 step = props.to_dict() 81 82 self.steps.append(step) 83 84 def build(self): 85 pipeline = {} 86 pipeline["steps"] = self.steps 87 88 if self.agents != None: 89 pipeline["agents"] = self.agents 90 if self.env != None: 91 pipeline["env"] = self.env 92 if self.notify != None: 93 pipeline["notify"] = self.notify 94 95 return pipeline 96 97 def to_json(self): 98 """Serialize the pipeline as a JSON string.""" 99 return json.dumps(self.build(), indent=4) 100 101 def to_yaml(self): 102 """Serialize the pipeline as a YAML string.""" 103 return yaml.dump(self.build())
class
Pipeline:
23class Pipeline: 24 """ 25 A pipeline. 26 """ 27 28 def __init__(self): 29 """A description of the constructor.""" 30 self.steps = [] 31 self.agents = None 32 self.env = None 33 self.notify = None 34 """I guess this is where we define the steps?""" 35 36 def add_agent(self, key: str, value: any): 37 if self.agents == None: 38 self.agents = {} 39 self.agents[key] = value 40 41 def add_environment_variable(self, key: str, value: any): 42 if self.env == None: 43 self.env = {} 44 self.env[key] = value 45 46 def add_notify(self, notify: PipelineNotify): 47 self.notify = notify 48 49 def add_step( 50 self, 51 props: Union[ 52 # classes 53 _block_step, 54 _command_step, 55 _group_step, 56 _input_step, 57 _trigger_step, 58 _wait_step, 59 # typed dicts 60 BlockStepArgs, 61 CommandStepArgs, 62 InputStepArgs, 63 GroupStepArgs, 64 TriggerStepArgs, 65 WaitStepArgs, 66 ], 67 ): 68 """Add a command step to the pipeline.""" 69 step = props 70 if isinstance( 71 props, 72 Union[ 73 _block_step, 74 _command_step, 75 _group_step, 76 _input_step, 77 _trigger_step, 78 _wait_step, 79 ], 80 ): 81 step = props.to_dict() 82 83 self.steps.append(step) 84 85 def build(self): 86 pipeline = {} 87 pipeline["steps"] = self.steps 88 89 if self.agents != None: 90 pipeline["agents"] = self.agents 91 if self.env != None: 92 pipeline["env"] = self.env 93 if self.notify != None: 94 pipeline["notify"] = self.notify 95 96 return pipeline 97 98 def to_json(self): 99 """Serialize the pipeline as a JSON string.""" 100 return json.dumps(self.build(), indent=4) 101 102 def to_yaml(self): 103 """Serialize the pipeline as a YAML string.""" 104 return yaml.dump(self.build())
A pipeline.
Pipeline()
28 def __init__(self): 29 """A description of the constructor.""" 30 self.steps = [] 31 self.agents = None 32 self.env = None 33 self.notify = None 34 """I guess this is where we define the steps?"""
A description of the constructor.
def
add_step( self, props: Union[buildkite_sdk.schema.BlockStep, buildkite_sdk.schema.CommandStep, buildkite_sdk.schema.GroupStepClass, buildkite_sdk.schema.InputStep, buildkite_sdk.schema.TriggerStep, buildkite_sdk.schema.WaitStep, buildkite_sdk.block_step.BlockStepArgs, buildkite_sdk.command_step.CommandStepArgs, buildkite_sdk.input_step.InputStepArgs, buildkite_sdk.group_step.GroupStepArgs, buildkite_sdk.trigger_step.TriggerStepArgs, buildkite_sdk.wait_step.WaitStepArgs]):
49 def add_step( 50 self, 51 props: Union[ 52 # classes 53 _block_step, 54 _command_step, 55 _group_step, 56 _input_step, 57 _trigger_step, 58 _wait_step, 59 # typed dicts 60 BlockStepArgs, 61 CommandStepArgs, 62 InputStepArgs, 63 GroupStepArgs, 64 TriggerStepArgs, 65 WaitStepArgs, 66 ], 67 ): 68 """Add a command step to the pipeline.""" 69 step = props 70 if isinstance( 71 props, 72 Union[ 73 _block_step, 74 _command_step, 75 _group_step, 76 _input_step, 77 _trigger_step, 78 _wait_step, 79 ], 80 ): 81 step = props.to_dict() 82 83 self.steps.append(step)
Add a command step to the pipeline.