I am using Jenkins for CI. I need to be able to pull a file from an S3 bucket. Inside the jenkins job I do the following diagnostic from the jenkins shell:

cd ~

this takes me to /var/lib/jenkins


this returns the user jenkins

inside /var/lib/jenkins I have my .aws folder with the config and credentials file, yet when I run

aws configure list

I get this:

      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

There is nothing there even though I have the .aws folder and the correct information in those two files. I originally tried placing the .aws folder in /home/jenkins but that didn't work either.

So, how do I get jenkins to actually work with the aws cli?

  • source the user configuration inside your jenkins build script. source ~/.bash_profile from there, you should be able to see the config/credentials files
    – crsuarezf
    Jan 30, 2018 at 21:31

5 Answers 5


You can export the credentials as environmental variables:

$ export AWS_DEFAULT_REGION=us-west-2

See http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html for more information. Depending on how you're using Jenkins you may want to use the EvnInject Plugin

  • I added this to the ./profile file, and ran source to ensure that the file is read. However, this didn't solve the issue of the “Unable to locate credentials” error
    – fuzzi
    Apr 17, 2018 at 19:25
  • Not working for me. Still unable to find credentials.
    – Jimmy
    Apr 4, 2019 at 11:18

Kindly update you aws credentials within the the bash of the jenkins server. Run the below commands:

# sudo -su jenkins
# aws configure

Reference Link: http://docs.aws.amazon.com/systems-manager/latest/userguide/sysman-ami-jenkins.html

  • My jenkins user has no HOME so it tries to save aws on the user I used when I run `sudo. Error: Permission denied: '/home/ubuntu/.aws/credentials Jul 27, 2017 at 4:51
  • I also got the Error: Permission denied: '/home/ubuntu/.aws/credentials
    – fuzzi
    Apr 17, 2018 at 14:50
  • I updated the permissions so that the jenkins user can read the file. However, now it throws a "Unable to locate credentials. " When I run "aws configure" the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are saved there already.
    – fuzzi
    Apr 17, 2018 at 16:04

This method worked for me:

  1. Make directory in /var/lib/jenkins that called .aws (or copy .aws folder from home directory if you already configured your aws credentials via "aws configure" command)
  2. Then go down to /var/lib/jenkins/.aws and write sudo shown -R jenkins ./ to change owner for files in .aws directory.

There's a similar problem that jenkins can't find credential small node program running by some bat. I've solved by changing home directory of jenkins which could be edited on jenkins configuration page into where the '.aws' folder is. (I've been configured the aws setting directly via remote desktop app)


If you are seeing this issue within corporate network while using instance role then please make sure the proxy settings are correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.