Created
December 5, 2023 22:06
-
-
Save robertwe/3bc0c6168eb2eafea8469b87dd7fb3d5 to your computer and use it in GitHub Desktop.
python yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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