Hello there,
First of all, great weekly posts (sarcasm). Today a coworker was needing help with problems on CI/CD in our homologation environment, the problem was simple but it can pass unnoticed and that is why I resolved to post it so it can help whom may need.
Here at my company we use a local Gitlab as repository and the Gitlab runner to build and deply our applications. I’m not very experienced with Gitlab but after a few troubleshootings in the past I understand how it works and where to look which can help a lot under this circunstanses.
Now the problem, one of my coworkers came to me with the error below on the pipeline and asking to add the permission to the AWS Key used on the pipeline to run our deploy on Homologation.
Looking at the AWS IAM the user had full permissions on the Bucket in question, so I asked my coworker to look at the project in Gitlab because theres two options, or the AWS Key is wrong or something changed in the project which in fact the runner changed, they started to use a runner in docker, prior was an EC2 that we used to have. So in this new context I went to check how the “.gitlab-ci.yml” was configurated and everything looked Ok, below is the code snippet of the deploy for homologation.
Going to ‘Settings -> CI / CD -> Variables’ the homolog key was indeed correct, so what was wrong? Maybe the Variable wasn’t been correct exported to the new Runner, so I went to check.
I first added the line - echo $AWS_ACCESS_KEY_ID
on the file “.gitlab-ci.yml” after the script:
section to be the first line executed, and as I thought the variable was empty.
Well, now I need to check if the variable from the Gitlab is being loaded in the runner, so I change the - echo $AWS_ACCESS_KEY_ID
to - export
to list all variables and everything seems ok.
Ps. I added within the brackets the reference of what it is so I won’t expose any sensitive information.
So the Gitlab indeed was fowarding the information but the runner wasn’t able to export to the variables.
Looking at the history of the “.gitlab-ci.yml” file I noticed something that my eyes didn’t notice, there was two variables:
in the file, one in the beggining and other in the end.
I removed the second reference and start the pipeline once more, and jackpot! The job finished successfully.
It was a easy fix mistake but I took a hour to find and resolve even after searched on google so I informed him and explain the changed made and ask him to pass to his team as well.
I hope you find this useful to your troubleshootings as well.