git - Are predefined variables in Gitlab CI/CD avaliable in .gitlab-ci.yml?
问题描述
I were trying to use CI_COMMIT_SHORT_SHA variable in config file (.gitlab-ci.yml), but it returned nothing.
I wanted to use CI_COMMIT_SHORT_SHA as part of directory name which were later pushed to the server by rsync. It should have returned short hash from current commit. Deployment passed successfully but the hash was empty.
deploy production:
...
script:
...
- VARIABLE_NAME=something_$CI_COMMIT_SHORT_SHA
- echo $VARIABLE_NAME
Code above return just something_
instead of e.g. something_aef34a4x
So can I use CI_COMMIT_SHORT_SHA or other predefined variables like this at all or what is the right way?
解决方案
GIT_COMMIT_SHORT_SHA
在 11.7 版本中引入:https ://docs.gitlab.com/ce/ci/variables/
正如您所发现的,当前 gitlab.com 已安装 11.6.2 版本,因此该变量不可用(还)。
推荐阅读
- c# - IFormFile 复制到内存流 ObjectDisposedException
- opentok - OpenTok SDK for Windows 何时支持 Web 代理
- jenkins - 找不到 Pmrep 命令 - jenkins
- php - 如何将一个表中的值插入到另一个表中?
- javascript - VSCode JSDoc - 定义动态属性类型
- git - 修复管理的 git 流
- javascript - jquery中具有多级子级的树表
- javascript - 基本 JavaScript 问题,井字游戏问题
- python - 在 CentOS 8 上使用 python 编译返回错误
- ggpubr - 如何在 ggbarplot 中使用 color_palette 和 fill_palette?