Gitlab CI作业失败:提交未签名(Commit is not signed)
GitLab CI作业因未签名提交失败的处理方案
错误日志详情
Getting source from Git repository Fetching changes with git depth set to 20... Reinitialized existing Git repository in /home/younes/Desktop/builds/PczuNw7zp/0/root/test/.git/ Checking out c2f1a8f3 as detached HEAD (ref is main)... Skipping Git submodules setup Executing "step_script" stage of the job script $ /home/younes/Desktop/script.sh Commit is not signed ERROR: Job failed: exit status 1
问题原因
你的CI脚本script.sh中包含提交签名校验逻辑,当前检出的提交c2f1a8f3未通过GPG签名验证,触发脚本报错并以状态码1退出,导致CI作业失败。
解决方法
- 补签提交:若该提交为你创建,本地切换到
main分支,执行git commit --amend --no-edit -S为提交补加GPG签名,之后推送更新到远程仓库。注意:若分支为多人协作分支,强制推送前需确认不会覆盖他人提交。 - 调整CI脚本:若无需强制校验提交签名,直接修改
script.sh,移除其中的签名检查代码段即可。 - 配置默认签名:如果仓库要求所有提交必须签名,可在本地Git配置中开启默认签名:
git config --global commit.gpgSign true,后续提交都会自动添加GPG签名。
内容的提问来源于stack exchange,提问作者Younes Lamhamedi Cherradi
相关产品推荐
相关产品推荐

