Skip to content

Adding ability to show terraform reports from child pipelines

What does this MR do and why?

Expose terraform reports from child pipelines to the merge request page. This is part of a larger effort to display all child reports.

This is scoped to

  1. Parent/Child pipelines
  2. Dynamic Child pipelines

We will not combine the reports, but show them separately.

It's behind a WIP FF - to be turned on after we've done the epic.

The performance of looking at child pipelines shouldn't be too bad: https://console.postgres.ai/gitlab/gitlab-production-ci/sessions/38957/commands/119733 - we don't have terraform reports on gitlab-project but it's still a good estimate

References

Screenshots or screen recordings

Before After

How to set up and validate locally

For 1. Parent child Pipelines

parent ci.yml

build-job:       # This job runs in the build stage, which runs first.
  stage: build
  script:
    - echo "Compiling the code23..."
    - echo "Compile complete."
  artifacts:
    reports:
      terraform: tfplan2.json
    paths:
      - tfplan2.json

trigger-job:
  trigger:
    include: downstream.yml

child ci.yml

build-tf:
  script: 
    - echo "tf"
  artifacts:
    reports:
      terraform: tfplan.json
    paths:
      - tfplan.json

tfplan.json
{
  "create": 1,
  "update": 2,
  "delete": 3
}

tfplan2.json
{
  "create": 1,
  "update": 2,
  "delete": 3
}

image.png

For dynamic child pipelines, similar to the above except you only need 1 ci.yml

stages:          # List of stages for jobs, and their order of execution
  - build
  - test
  - deploy

generate-config:
  stage: build
  script:
    - echo "Generating config"
    - |
      cat > generated-config.yml <<EOF
      build-tf:
        stage: build
        script: 
          - echo "tf"
        artifacts:
          reports:
            terraform: tfplan.json
          paths:
            - tfplan.json
      EOF
  artifacts:
    paths:
      - generated-config.yml

child-pipeline:
  stage: test
  trigger:
    include:
      - artifact: generated-config.yml
        job: generate-config

image.png

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #363306 (closed)

Edited by Max Fan

Merge request reports

Loading