0
votes

Background

I am attempting to upload a file to an AWS S3 bucket in Jenkins. I am using the steps/closures provided by the AWS Steps plugin. I am using an Access Key ID and an Access Key Secret and storing it as a username and password, respectively, in Credential Manager.

Code

Below is the code I am using in a declarative pipeline script

sh('echo "test" > someFile')
            
withAWS(credentials:'AwsS3', region:'us-east-1') {
    s3Upload(file:'someFile', bucket:'ec-sis-integration-test',  acl:'BucketOwnerFullControl')
}
            
sh('rm -f someFile')

Here is a screenshot of the credentials as they are stored globally in Credential Manager.

enter image description here

Issue

Whenever I run the pipeline I get the following error

com.amazonaws.services.s3.model.AmazonS3Exception: Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID: 5N9VEJBY5MDZ2K0W; S3 Extended Request ID: AJmuP635cME8m035nA6rQVltCCJqHDPXsjVk+sLziTyuAiSN23Q1j5RtoQwfHCDXAOexPVVecA4=; Proxy: null), S3 Extended Request ID: AJmuP635cME8m035nA6rQVltCCJqHDPXsjVk+sLziTyuAiSN23Q1j5RtoQwfHCDXAOexPVVecA4=

Does anyone know why this isn't working?

Trouble Shooting

I have verified the Access Key ID and Access Key Secret combination works by testing it out through a small Java application I wrote. Additionally I set the id/secret via Java system properties ( through the script console ), but still get the same error.

System.setProperty("aws.accessKeyId", "<KEY_ID>")
System.setProperty("aws.secretKey", "<KEY_SECRET>")

I also tried to change the credential manager type from username/password to aws credentials as seen below. It made no difference

different credential type

1

1 Answers

1
votes

it might be a bucket and object ownership issue. check if the credentials you use allow you to upload to the bucket ec-sis-integration-test.