Hello everyone. I don’t know if this is the right way to save code lines or if there is another possibility to run different environments with the same deploy stage.
stages:
- deploy
My case. I want to deploy the staging system and the production system in the same way. To do this, I wrote a rule block to define the envioronment in a environment variable which is initialized like this:
So I’m a bit confused that the variables are available for the main branch (production environment) but not for the release branch (staging environment).
I think it has anything to do with my workflow part but I’m not sure.
I’m not so fimilar with the gitlab ci yaml and maybe it is nonsense to use a variable for the environment name.
Hope anyone can help me.
If I solve this issue on my own, I will share you the solution right here
Are your release branches protected? If not, is the reason. Your CI variable SSH_PRIVATE_KEY is labeled as protected, which means it will be available only in protected branches (which probably your main branch is, and that’s why it works there).
So, the solution would be either to protect your release branches, or to remove protected checkbox from your CI variables. The rest looks pretty fine.