Infra validate job to checkout repo if pipeline definition is not from self.
Issue
Currently the pipelines for infrastructure would be running only if they are created in the same infra repo. When tried to create referencing the tasks in the infra repo jobs of validation start failing. The prepare stage is currently tied up as pre-requisite for the build-stage & deploy-stage.
The prepare-stage has a validation job that verifies the infra templates before building and triggering for deployment. The Lint Go
and the Lint TF
steps in the validate job fail if the pipeline is created outside of the repo.
Note: Similar issue happens with gitops helm chart location repo as well.
Fix
With the infra repo being made to checkout explicitly as step during the validation it seems to be resolved. Since the sample pipelines are within the same repo this issue hasn't been surfaced.
Option 1
We can always take input of the infra repo resource and do a checkout of the repo in the validation job steps. This would require top level jobs to pass in the correct repo to checkout i.e. either self checkout in case of same location hosted pipelines or specific repository resource input for externalized pipelines.
Option 2
We can have a constant defined as we have for MANIFEST_REPO
calling it as INFRA_REPO
and checkout using that variable with a condition if it is not empty or Null value.