本文共 2014 字,大约阅读时间需要 6 分钟。
How do I prevent a gitlab ci pipeline being triggered when I add a git tag? I'm running this command locally (as opposed to within a gitlab-ci job)
git tag -a "xyz"
and then pushing the tag; and this triggers various pipelines. I want to exclude some of those pipelines from running.
I'm trying variations on ideas from questions such as this; that question is using only, I'm wanting to exclude, so I'm trying except. The answers there have two variants, one with refs one without.
build:
# ... my work here ...
except:
- tags
build:
# ... my work here ...
except:
refs:
- tags
Neither seem to have any effect; I add a tag, the build still happens.
My understanding may be completely awry here as there seem to be three possible meanings of the word tags and when reading docs or examples I'm not always sure which meaning is applicable:
Git tags applied using git tag
Gitlab CI tags used to determine which runners pick a job
The ref identifier of a commit used to trigger a pipeline via the REST API. This is usually a branch name, but could be a git tag.
I'm interested in controlling what happens if the first case. It does seem clear from comments so far that "except: -tags" is not relevant to my case, so is there any approach that does work?
解决方案
Except tags is exactly what you should use if you want to skip build for tags.
You need to be sure to understand commit vs branches vs tags
To illustrate what happens when you push tagged commit to gitlab I did as follows:
Created .gitlab-ci.yml with following content:
tests_always_run:
script:
- echo I should always execute
tests_except_tags:
script:
- echo I skip tagged triggers
except:
- tags
Commited changes, tagged commit and pushed with --follow-tags to make sure tag is also propagated to server:
git add .gitlab-ci.yml
git commit -m 'my great yml with except tags'
git tag -a "abc" -m "Test tag"
git push --follow-tags
Ilustrated results:
If you want to skip CI for selected commit then you could use git push -o ci.skip, inspired by this article
转载地址:https://blog.csdn.net/weixin_33648352/article/details/118804855 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!