.install-prerequisites: &install_prerequisites
before_script:
- apt -qq update
- apt -q -y install curl
build-kubectl:
stage: build
<<: *install_prerequisites
script:
- curl .....
Hope this helps
Thank you for the clear answer and this convenient shortcut! I’ll give that a try. I didn’t want to have to maintain an image simply for a handful of packages-- it is overkill.
I’m surprised to learn that GitLab can’t cache things like /usr/bin between layers. I’ll try to learn more about that.
slasiewski:
I’m surprised to learn that GitLab can’t cache things like /usr/bin between layers. I’ll try to learn more about that.
Jobs that use an image
will always spawn a new container, controlled by GitLab Runner.
If you want to persist the installation of specific packages or tools, it is recommended to create a custom container image, push it to the GitLab container registry, and use the image in the CI/CD jobs. More in Pipeline efficiency | GitLab
dnsmichi:
If you want to persist the installation of specific packages or tools, it is recommended to create a custom container image, push it to the GitLab container registry, and use the image in the CI/CD jobs. More in Pipeline efficiency | GitLab
I think you’re saying that I should do the following in my CI pipeline:
Use a job to build an image & push it to the registry
In subsequent jobs, pull it from the registry and run my tests.
Can you clarify? The document suggested above doesn’t describe how to use a custom image as part of a workflow & I haven’t had luck searching on my own. Can you point me to some documentation that describes this?
Edit: I found the following blog post about building a build image first (a meta-build-image). Is that what you are describing? Getting [meta] with GitLab CI/CD: Building build images