I'm setting up a deployment process for my website with gitlab CI.
I have a production
website and a sub-domain with a staging
deployment.
Let's say I have different branches among them : master and release. I have a file .yaml that is configured such that :
if I push on master, I have a deployment on production
(with a manual option) and if I push on my branch release, I have an automatic deployment on staging
.
git push origin master
deploys to production (with manual validation),
git push origin release
deploys to staging. And any other branch that are pushed do not deploy.
We are several guys to work and, sometimes, we would like to be able to deploy another branch (e.g. feature
) on staging
when specifying a tag (e.g. specifictag
) on a git push :
git tag specifictag
git push origin feature --tags
This would be useful for me because sometimes some developers would like to test their codes before merging to release and we don't want to create a third environment. And of course we don't want to deploy every time we push on any branch.
stages:
- staging
- production
test-deployment:
stage: staging
script:
- [...]
only:
- release
tags:
- extranetserver
prod-deployment:
stage: production
script:
- [...]
only:
- master
tags:
- extranetserver
when: manual
Has anyone an idea on how to use tag as a way to force a deployment when a specific tag is pushed ? Thanks!
NOTE: Note: The environment keyword defines where the app is deployed. The environment name and url is exposed in various places within GitLab. Each time a job that has an environment specified succeeds, a deployment is recorded, along with the Git SHA, and environment name.
These are scripts that you choose to be run before the job is executed or after the job is executed. These can also be defined at the top level of the YAML file (where jobs are defined) and they'll apply to all jobs in the . gitlab-ci. yml file.
gitlab-ci. yml , you can specify some jobs with the tag testing . If a runner with this tag associated is available, it will pickup the job. In Git, within your repository, tags are used to mark a specific commit.
You can use regex, like
test-deployment:
only:
- /^staging-/
And tag your commit, begin with "staging-". When you push, the job should run.
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