Skip to content

Instantly share code, notes, and snippets.

@robertwe
Created December 5, 2023 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertwe/3bc0c6168eb2eafea8469b87dd7fb3d5 to your computer and use it in GitHub Desktop.
Save robertwe/3bc0c6168eb2eafea8469b87dd7fb3d5 to your computer and use it in GitHub Desktop.
python yaml
import yaml
def extract_pipeline_info(yaml_file):
with open(yaml_file, 'r') as file:
yaml_data = yaml.safe_load(file)
pipeline_info = []
for stage in yaml_data.get('stages', []):
stage_name = stage.get('stage', '')
pipeline_info.append(f"## Stage: {stage_name}\n")
for job in stage.get('jobs', []):
job_name = job.get('job', '')
pipeline_info.append(f"### Job: {job_name}\n")
for step in job.get('steps', []):
step_name = step.get('displayName', '')
pipeline_info.append(f"#### Step: {step_name}\n")
return '\n'.join(pipeline_info)
if __name__ == "__main__":
yaml_file = 'your_pipeline.yaml'
pipeline_info = extract_pipeline_info(yaml_file)
with open('pipeline_documentation.md', 'w') as output_file:
output_file.write(pipeline_info)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment