Allow Terraform reports to be read for pipelines with a Blocked/Incomplete state
Proposal
This request is similar to Allow security reports to be read for pipelines with a Blocked/Incomplete state feature request. I am splitting it for Terraform reports because it is a different group that might decide to schedule it differently.
In the majority of cases, teams will configure their pipelines to execute the terraform plan
job automatically and terraform deploy
job manually in later stages. It is crucial for the team to look at the reports BEFORE executing the last job of the pipeline which is manual and triggers the terraform apply
. However, because we only load the terraform artifact for completed pipelines, loading of terraform artifacts never happens unless the last manual apply
job is executed.
The only workaround right now is to mark the manual job that runs terraform apply
as allow_failure: true which makes the job complete even if the manual job is blocked or failed.
Implementation Guide
The MergeRequest model has the following method to determine if the pipeline is complete and has a Terraform report:
def has_terraform_reports?
actual_head_pipeline&.complete_and_has_reports?(Ci::JobArtifact.of_report_type(:terraform))
end
Instead of #complete_and_has_reports?
, which requires the pipeline to be finished, we should be able to use #has_reports?
instead.