'YAML Pipeline Scan python

I have to write a python script where I need to parse YAML file and produce the list of steps that includes the image version for example: this is the step

Step 1:
  stage: setup
  description: 
  title: Check plugin
  fail_fast: false
  *image: 'Image-Name'*
  commands:
    - apt update

Fetch the images version under the particular stage and lists all steps and the version of the image used by each step. Output should be in list

Step 1:
   robot_image:1.0.1

Data is in Variable and its showing as string type and now need to filter it base on the Step and print the image with step

unit_test:
    stage: build
    fail_fast: false
    title: Generate test results report
    type: freestyle
    image: 'docker-test-reporting.1.0'


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source