I've read documentation, some articles and you might call me dumb, but this is my first time working with a concept like this.
BUT how exactly is running my jobs dependent on those tags? Are all these operations necessary? If I push new code to repo, *.yml file is executed anyway as far as I tested.
So what if I want to run build only when I define a version in a commit?
IDK...
git commit --tags "v. 2.0" -m "this is version 2.0" (probably not right)
But of course it should be universal, so I don't have to always tell, which tag to use to trigger the runner, but for example let him recognize numeric values.
As you can see, I'm fairly confused... If you could elaborate how exactly tags work, so I would be able to understand the concept, I would be really grateful.
In Git, within your repository, tags are used to mark a specific commit. It is often used to tag a version. The two concepts can be mixed up when you use tags (in Git) to start your pipeline in GitLab CI. In your . gitlab-ci.
Tags help you mark certain deployments and releases for later reference. Git supports two types of tags: Annotated tags: An unchangeable part of Git history. Lightweight (soft) tags: Tags that can be set and removed as needed.
The difference between tags and branches are that a branch always points to the top of a development line and will change when a new commit is pushed whereas a tag will not change. Thus tags are more useful to "tag" a specific version and the tag will then always stay on that version and usually not be changed.
In order to list Git tags, you have to use the “git tag” command with no arguments. You can also execute “git tag” with the “-n” option in order to have an extensive description of your tag list. Optionally, you can choose to specify a tag pattern with the “-l” option followed by the tag pattern.
Tags for GitLab CI and tags for Git are two different concepts.
When you write your .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. It is often used to tag a version.
The two concepts can be mixed up when you use tags (in Git) to start your pipeline in GitLab CI. In your .gitlab-ci.yml
, you can specify the section only
with tags
.
Refer to GitLab documentation for tags and only.
An example is when you push a tag with git:
$ git tag -a 1.0.0 -m "1.0.0" $ git push origin 1.0.0
And a job in .gitlab-ci.yml
like this:
compile: stage: build only: [tags] script: - echo Working... tags: [testing]
would start using a runner with the testing
tag.
By my understanding, what is missing in your steps is to specify the tag testing
to your runner. To do this, go in GitLab into your project. Next to Wiki, click on Settings. Go to CI/CD Pipelines and there you have your runner(s). Next to its Guid, click on the pen icon. On next page the tags can be modified.
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