I want to use Gitlab CI/CD for deployment. The same codebase is used to deploy to different environments and requires a statefile (state of environment) for deployment, which need to be updated after the deployment, and fetched before deployment. As it is a critical piece of information I want it to be a build artifact.
Consider my deployment pipeline and different jobs deploy-env1
and deploy-env2
. Is it possible to define the jobs in a way they
state.dat
as a build artifact (easy using the artifacts
option)As it seems I currently cannot configure a job to depend on itself, do you know if there is a way to realize this?
No there is no implemented function to handle this.
But there is a possible work around, I haven't tried this yet, and a 3rd party solution.
The workaround: You can build yourself a script which uses the Gitlab Jobs API to download the latest artifacts for your branch. Example in the Gitlab docs
Another workaround: Intstead of the downloading using the API you can also use a combination of artifacts and cache objects
The clean solution: Would be set up a artifact service which is not provided by Gitlab. You would deploy your file there and would it then retrieve again from the same service. Such programs are Artifactory and Nexus
Instead of using the jobs api, you can download it directly via URL
You should consider using Dependencies along with the Artifacts: https://docs.gitlab.com/ee/ci/yaml/#dependencies
build:
artifacts:
paths:
- state.dat
deploy-env1:
dependencies:
- build
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With