Issue
In Jenkins Job I'm trying to login to WAS CLI with a script:
eval $(echo $(aws ecr get-login --no-include-email --region=eu-north-1))
When I do it manually all works fine.
$(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
But when Jenkins try to run it I get log:
+ aws ecr get-login --no-include-email --region=eu-north-1 Unable to locate credentials.
You can configure credentials by running "aws configure".
More represented view of the problem is:
$ 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
How to assign the same key access for use jenkins
role to existed keys?
Solution
Note: Not sure if it is recommended, but this worked for me:
sudo -su jenkins
cd /var/lib/jenkins/
mkdir .aws
then create credentials and config files.
then if you do aws configure list, it doesn't actually show the profiles added but it works while running the junkins job.
Answered By - james
Answer Checked By - Candace Johnson (JavaFixing Volunteer)