在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
角色的现有键分配相同的键访问权限?
答案 0 :(得分:1)
注意::不确定是否建议这样做,但这对我有用:
sudo -su jenkins
cd /var/lib/jenkins/
mkdir .aws
然后创建凭据和配置文件。
然后,如果您执行aws configure列表,它实际上不会显示已添加的配置文件,但在运行“垃圾邮件”作业时可以使用。
答案 1 :(得分:-1)
我已经通过更改用户来修复它。 (先决条件:安装 awscli
,最新)
userabc$ sudo su
root$ su jenkins
jenkins$ aws configure
(但首先需要在 IAM 上创建程序化账户,然后在 Jenkins 用户中配置 AWS 账户)。