如果触发作业的标签是在 master 上创建的,则运行作业
我的配置看起来像这样:
java-prod-build:
stage: build
only:
- tags
before_script:
- env
- declare RELEASE_VERSION=$(echo "$CI_COMMIT_TAG" | sed 's/.*-//') && echo $RELEASE_VERSION
- echo $CI_COMMIT_SHA && echo $CI_JOB_STARTED_AT
script:
- ...
仅当标签是在“属于”主分支的提交上创建的时,我才愿意运行该脚本。
不幸的是,扫描变量发现典型字段现在包含标签名称:
CI_COMMIT_REF_NAME=rpk-10.9.117, CI_BUILD_REF_NAME=rpk-10.9.117
有一个简单的方法吗?
我对 GitLab-CI 的东西还很陌生,在阅读文档时我找不到任何足够具体的内容来帮助我:/
感谢您的帮助!
my configurations looks something like this:
java-prod-build:
stage: build
only:
- tags
before_script:
- env
- declare RELEASE_VERSION=$(echo "$CI_COMMIT_TAG" | sed 's/.*-//') && echo $RELEASE_VERSION
- echo $CI_COMMIT_SHA && echo $CI_JOB_STARTED_AT
script:
- ...
I would love to run that script only if the tag was created on a commit that "belongs" to the master branch.
Unfortunately scanning through the variables reveals that the typical fields now contain the tag name:
CI_COMMIT_REF_NAME=rpk-10.9.117,
CI_BUILD_REF_NAME=rpk-10.9.117
Is there an easy way of doing it?
I am pretty new to GitLab-CI stuff and reading the documentation I can't find anything specific enough to help me out :/
Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你会做这样的事情(抱歉格式不好,但你明白了):
比“仅”更好的方法,这不是 积极开发,将使用 规则:如果。
您还可以检查 CI/CD 环境变量 来帮助您实现你的目标。
未经测试,但它可能看起来像这样:
我将让您摆弄变量和
if
规则以满足您的需求You would do something like this (sorry for the poor formatting, but you get the idea):
A better way than "only", which is not actively developed, would be to use rules:if.
You can also check the CI/CD env variables to help you achieve your goal.
Not tested, but it could look something like this:
I'll let you fiddle with variables and
if
rules to suit your needs