linux - Jenkins 不能使用 aws-cli 密钥。无法找到 AWS CLI 的凭证
问题描述
在 Jenkins Job 中,我尝试使用脚本登录 WAS CLI:
eval $(echo $(aws ecr get-login --no-include-email --region=eu-north-1))
当我手动完成时,一切正常。
$(echo $(aws ecr get-login --no-include-email --region=eu-north-1))
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
WARNING! Your password will be stored unencrypted in /home/ubuntu/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
但是当詹金斯尝试运行它时,我得到了日志:
+ aws ecr get-login --no-include-email --region=eu-north-1 Unable to locate credentials.
You can configure credentials by running "aws configure".
问题的更多代表观点是:
$ sudo -H -u ubuntu aws configure list
Name Value Type Location
---- ----- ---- --------
profile <not set> None None
access_key ****************L7YQ shared-credentials-file
secret_key ****************dr46 shared-credentials-file
region eu-north-1 config-file ~/.aws/config
$ sudo -H -u jenkins aws configure list
Name Value Type Location
---- ----- ---- --------
profile <not set> None None
access_key <not set> None None
secret_key <not set> None None
region <not set> None None
如何为jenkins
现有密钥分配相同的密钥访问权限以使用角色?
解决方案
注意:不确定是否推荐,但这对我有用:
sudo -su jenkins
cd /var/lib/jenkins/
mkdir .aws
然后创建凭据和配置文件。
然后,如果您执行 aws configure list,它实际上不会显示添加的配置文件,但它在运行 junkins 作业时有效。
推荐阅读
- javascript - 在 Web 控制台中获取 NAN (JavaScript)
- javascript - 如何重新启动 Javascript 或结合 onclick mouseenter mouseleave?
- android - 我的应用程序被视为未知应用程序
- cmake - 选项(
“帮助字符串描述选项”[初始值])将其设置为 ON 或 OFF 但我很困惑 - c# - 使用 C# 将行添加到文件工具提示
- jquery - DatePicker 没有格式
- c# - 项目名称和命名空间更改后 Web api 不起作用
- java - Spring boot:如何将thymeleaf转换为jsp
- angular - Angular 6 测试类的模拟依赖
- r - 在 R Shiny 中为 output$arg 传递参数时遇到问题