用bash代码定义gitlab中的CI/CD管道中的变量?
我想以这种精神定义Gitlab的CI/CD管道(.gitlab-ci.yml)中的变量:
variables:
- TOP_DIR=$(git rev-parse --show-toplevel)
但是这不起作用,我认为,因为值字段必须是实际的字符串。有解决方法吗?我是否应该创建一个初步的作业,export top_dir = $(git rev-parse -show-toplevel)
?
I would like to define a variable in Gitlab's CI/CD pipeline (.gitlab-ci.yml) in this spirit:
variables:
- TOP_DIR=$(git rev-parse --show-toplevel)
But this doesn't work, I think because the value field must be an actual string. Any workaround? Should I just create a preliminary job that does export TOP_DIR=$(git rev-parse --show-toplevel)
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
导出脚本顶部的变量。
Gitlab有许多有用的预定的环境变量您可以在
.gitlab-ci.yml
。Export the variable at the top of your script.
GitLab has a number of useful predefined environment variables that you can reference in
.gitlab-ci.yml
.