Passing Artifacts between Branches

Hey everyone;

I’m looking for the proper or available way to do artifact

I’m using Gitlab CI/CD as my terraform planning and deployment method. In stage ‘plan’ it creates the plan file per project directory, and at the end it stores the artifacts of each project directory.

In order for users to apply them, they have to submit a merge request, and once approved, it’ll run the stage ‘apply’ where it’s supposed to pull down the artifact and apply. Except because now it’s a pipeline running on the main branch, there’s no artifact for it to pull down. I can specify in the CI/CD pipeline to pull down an artifact based on the source branch name:

 curl -k --location --header "PRIVATE-TOKEN:super_secret_token" "https://gitlab.my_domain.tld/api/v4/projects/2/jobs/artifacts/my_source_branch_name/download?job=terraform_plan" -o

Replacing my_source_branch_name with $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME from the predefined variables. Except if the branch gets deleted, as it is an option in the merge request, it can’t pull it down.

So my only bet is to do something like an external artifact storage where I can pass the branch name as a folder structure? Unless there’s something else I can do with Gitlab?


Running Gitlab Self Hosted 13.10.0-ee

What if you don’t let the developer able to delete the source branch after merge. It can be done in the settings.

I don’t see how you can do that. I can see how you leave the box unchecked, but is it in the admin panel to remove that option?