提问人:Highnoon 提问时间:11/17/2023 更新时间:11/17/2023 访问量:25
在 GitLab CI/CD 管道中遇到 Ubuntu 存储库的 GPG 错误
Encountering GPG Errors with Ubuntu Repositories in GitLab CI/CD Pipeline
问:
我目前正在做一个项目,该项目使用 Docker 和映像在 GitLab 中设置 CI/CD 管道。上个月也运行良好。但是,在过去的几天里,它不再起作用了。我在该步骤中遇到了一个问题,由于与 Ubuntu 存储库相关的 GPG 错误,它失败了。这是我文件的相关部分:ubuntu
apt-get update
.gitlab-ci.yml
manage-releases:
stage: manage-releases
needs:
- job: release_job
image: ubuntu # Also tried with ubuntu:latest or specific version numbers, didn't change anything
before_script:
- apt-get clean # I already added this because I read that this would solve the issue. But it didn't.
- apt-get -qq update
- apt-get install -y jq curl
script:
- sh manage_releases.sh # Execute a script that requires jq package
我遇到的错误如下:
...
$ apt-get clean
$ apt-get -qq update
W: GPG error: http://archive.ubuntu.com/ubuntu jammy InRelease: At least one invalid signature was encountered.
E: The repository 'http://archive.ubuntu.com/ubuntu jammy InRelease' is not signed.
W: GPG error: http://archive.ubuntu.com/ubuntu jammy-updates InRelease: At least one invalid signature was encountered.
E: The repository 'http://archive.ubuntu.com/ubuntu jammy-updates InRelease' is not signed.
W: GPG error: http://archive.ubuntu.com/ubuntu jammy-backports InRelease: At least one invalid signature was encountered.
E: The repository 'http://archive.ubuntu.com/ubuntu jammy-backports InRelease' is not signed.
W: GPG error: http://security.ubuntu.com/ubuntu jammy-security InRelease: At least one invalid signature was encountered.
E: The repository 'http://security.ubuntu.com/ubuntu jammy-security InRelease' is not signed.
有关如何排除和解决这些错误的任何见解或建议将不胜感激!谢谢:)
答:
0赞
Vishal A K
11/17/2023
#1
此错误表示 Ubuntu 存储库的 GPG 密钥签名在您的系统上无效/不受信任。
要修复它,您需要更新受信任的 GPG 密钥列表。运行以下命令:
sudo apt update
sudo apt install debian-archive-keyring ubuntu-keyring
这将下载并安装最新的受信任密钥。
然后尝试运行或再次运行。存储库现在应该正确验证,没有错误。apt update
apt-get update
需要注意的一些事项:
- 由于安全或其他原因,Ubuntu 可能更改了密钥,这会导致缓存的密钥无效
- 系统时钟可能不准确,导致签名验证失败
- 您之前可能手动删除或更改了密钥环文件
在大多数情况下,如上所示重置密钥环应该可以通过从密钥服务器下载新的受信任密钥来解决该问题。
评论
0赞
Highnoon
11/17/2023
谢谢你的回答!如何运行 sudo 命令?我只是把它们放在 中,还是有其他方法?before_script
0赞
Vishal A K
11/18/2023
您可以在执行脚本之前运行这些命令,也可以在脚本的开头添加这些命令。
评论