Search code examples
amazon-web-servicesdockerjenkinsamazon-ecs

jenkins docker on aws


I am running jenkins off an ec2 image and building a docker image to push into ecr

I keep getting this error

Running shell script
+ aws ecr get-login --no-include-email --region us-east-2
Unable to locate credentials. You can configure credentials by running "aws configure".

I have tried to create the credentials file ie

touch ~/.aws/credentials and echo >> to the file

I have tried with

--build-arg AWS_ACCESS_KEY_ID=xxxxxxx

and I have also added my credentials into Jenkins

Please any help would be appreciated


Solution

  • You can fix this by configuring aws cli by jenkins user. Just fire this command as jenkins user and mention your access key and secret key along with the AWS region.

    First change to Jenkins user

    [root@symphony ~]# su -s /bin/bash jenkins 
    

    Then configure AWS CLI

    [jenkins@symphony ~]$ aws configure
    AWS Access Key ID [None]: xxxxxxxxxxxxxxxx
    AWS Secret Access Key [None]: yyyyyyyyyyyy
    Default region name [None]: us-east-2
    Default output format [None]:
    

    Verify the aws cli with this command

    [jenkins@symphony ~]$ aws ecr get-login --no-include-email --region us-east-2
    

    NOTE: Make sure your user has access to ECR and ECS.