GitLab - extends keyword
In the previous post I had written about the include keyword. Now, let's dive in the extends keyword. What can you do with this? Here is the definition from GitLab documentation: extends defines entry names that a job that uses extends inherits from. It’s an alternative to using YAML anchors and is a little more flexible and readable. So, when is it useful? It is useful when you want to be DRY and keep your setup cleanly. Let's assume that you want to build a docker image and give developers possibility to deploy the image on dev , staging and prod environments. We are going to do that without the extends keyword, and after that we will think how we can do it better. Example without the extends keyword: As you can see, there is a lot of code which repeats itself: stage, image, when and script . We can remove a lot of code! So, let's do that. We are going to create a hidden job .deploy (you will not see this job in a pipeline) and the rest of the jobs will in
Comments
Post a Comment