Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only use accessKey and secretKey if they are not blank #265

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,12 @@
public AwsCredentials resolveCredentials() {

if (StringUtils.isBlank(iamRoleArn)) {
return AwsBasicCredentials.create(accessKey, secretKey.getPlainText());
if (StringUtils.isBlank(accessKey) && StringUtils.isBlank(secretKey.getPlainText())) {
// AWS SDK v2 does not allow blank accessKey and secretKey
return null;

Check warning on line 174 in src/main/java/com/cloudbees/jenkins/plugins/awscredentials/AWSCredentialsImpl.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 172-174 are not covered by tests
} else {
return AwsBasicCredentials.create(accessKey, secretKey.getPlainText());
}
} else {
AwsCredentialsProvider baseProvider;
// Handle the case of delegation to instance profile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,10 @@
AwsCredentials credentials = provider.resolveCredentials();

Map<String, String> m = new HashMap<String, String>();
m.put(accessKeyVariable, credentials.accessKeyId());
m.put(secretKeyVariable, credentials.secretAccessKey());
if (credentials != null) {

Check warning on line 142 in src/main/java/com/cloudbees/jenkins/plugins/awscredentials/AmazonWebServicesCredentialsBinding.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 142 is not covered by tests
m.put(accessKeyVariable, credentials.accessKeyId());
m.put(secretKeyVariable, credentials.secretAccessKey());
}

// If role has been assumed, STS requires AWS_SESSION_TOKEN variable set too.
if (credentials instanceof AwsSessionCredentials) {
Expand Down
Loading