Gitlab管道| ci_commit_before_sha在$ ci_pipeline_source ='web的情况下为零。
试图在新主管之前检索主要分支机构的最新提交。
但是使用ci_commit_before_sha
其返回始终为零。如果我从gitlab UI运行管道。
如果将其推到主分支,则可以自动触发,如果它自动触发,则可以正常工作。
- nx_head = $
- nx_base = $ {ci_merge_request_diff_base_sha: - $ ci_commit_before_sha}
Trying to retrieve latest commit in main branch before the new head.
But using CI_COMMIT_BEFORE_SHA
its returning always zero's. In case, if I run pipeline from the GitLab UI.
It working fine if its trigged automatically in case of a push to main branch.
Pipline Custome Variables using Predefined Gitlab CI variables:--
- NX_HEAD=$CI_COMMIT_SHA
- NX_BASE=${CI_MERGE_REQUEST_DIFF_BASE_SHA:-$CI_COMMIT_BEFORE_SHA}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查这是否与问题12850 /code>在合并请求管道中均为零”。
或问题28252
ci_merge_request_target_branch_sha
在分离的合并请求管道中“尝试一个简单的测试,以查看您当前版本的gitlab:是否可以更好地工作:
Check if this is related to issue 12850 "
CI_COMMIT_BEFORE_SHA
is all zero in a merge request pipeline".Or issue 28252 "Expose
CI_MERGE_REQUEST_SOURCE_BRANCH_SHA
andCI_MERGE_REQUEST_TARGET_BRANCH_SHA
in detached merge request pipelines"Try a simple test to see if that would work better with your current version of GitLab:
我猜想您的管道的灵感来自使用gitlab and nx 配置CI。
如果是这样,您可以将
git_depth
设置为0
,该根据文档应该禁用浅克隆。不幸的是,看来这是无法预期的,请参见 a>。因此,也许您想更改
为
以便最后100个提交(而不是默认),然后希望它会导致
$ ci_commit_before_sha
在非MR Pipeline中定义。此博客可能也很有趣。
I am guessing your pipeline is inspired by Configuring CI Using GitLab and Nx.
If so, you might have set
GIT_DEPTH
to0
which according to the docs should disable the shallow cloning. Unfortunately, it looks like this doesn't work as expected, see issues 292470.Therefore, maybe you'd like to change
to
so that the last 100 commits (instead of the default) are available, which then hopefully will result in
$CI_COMMIT_BEFORE_SHA
being defined in a non-MR pipeline.This blog might also be interesting.