我有这个工作流程/职位Circle Ci:
build:
docker:
- image: circleci/python:3.7
environment:
PIPENV_VENV_IN_PROJECT: true
steps:
- checkout
#other stuff here -> installing dependencies
- run:
name: Running blackbox
command: |
git clone https://github.com/StackExchange/blackbox.git
cd blackbox && sudo make symlinks-install && cd ..
echo "Importing key"
echo -e "$GPG_KEY_CI" | gpg --import
blackbox_postdeploy
在管道运行时,我陷入了将近3个小时的错误“ gpg:解密失败:没有密钥” 。我已经在Circle Ci上将GPG_KEY_CI设置为环境变量,并且对“ echo gpg --list-secret-keys”做了一些测试,以检查是否导入了私钥(私钥)。因此,一切看起来都正确。
以下是输出:
Cloning into 'blackbox'...
remote: Enumerating objects: 18, done.
remote: Counting objects: 100% (18/18), done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 2151 (delta 6), reused 7 (delta 2), pack-reused 2133
Receiving objects: 100% (2151/2151), 617.31 KiB | 1.10 MiB/s, done.
Resolving deltas: 100% (1369/1369), done.
Symlinking files from ./bin to /usr/local/bin
Done.
Importing key
gpg: directory '/home/circleci/.gnupg' created
gpg: keybox '/home/circleci/.gnupg/pubring.kbx' created
gpg: /home/circleci/.gnupg/trustdb.gpg: trustdb created
gpg: key 9FxxxxxxxxxxxxD9: public key "Circle Ci <xxxxxxxxxx@gmail.com>" imported
gpg: key 9FxxxxxxxxxxxxD9: secret key imported
gpg: Total number processed: 1
gpg: imported: 1
gpg: secret keys read: 1
gpg: secret keys imported: 1
========== Importing keychain: START
gpg: Total number processed: 1
gpg: unchanged: 1
========== Importing keychain: DONE
========== Decrypting new/changed files: START
gpg: decryption failed: No secret key
答案 0 :(得分:0)
3小时后,我意识到导出的密钥带有保护私钥的密码。因此,请按照以下步骤再次导出私钥:
1)首先列出要获取指纹的键:
>> gpg --list-secret-keys
/Users/xxxxxx/.gnupg/pubring.kbx
--------------------------------
sec rsa2048 2019-11-16 [SC] [expires: 2021-11-15]
FED8634xxxxxxxxxxxxxxxxxxxxxx1E4C7020D9 <====== fingerprint
uid [ultimate] Circle Ci <xxxx+circleci@gmail.com>
ssb rsa2048 2019-11-16 [E] [expires: 2021-11-15]
2)从您的私钥中删除通行证。当GnuPG提示输入新密码时,请将其保留为空白,然后按Enter(两次):
>> gpg --edit-key <fingerprint>
passwd
3)再次将私钥导出到剪贴板(pbcopy将stdin复制到剪贴板):
>> gpg -a --export-secret-keys <fingerprint> | cat -e | sed 's/\$/\\n/g' | pbcopy
4)替换Circle Ci环境变量上的键