Skip to content
Permalink
Browse files

[JENKINS-9556] configuring job without configuring any cloudbees acco…

…unt throw a NPE
  • Loading branch information...
olamy committed May 2, 2011
1 parent db46b81 commit 37157c3c44b150ddb0e384f279c4093f00a8c39e
Showing with 13 additions and 3 deletions.
  1. +13 −3 src/main/java/org/jenkins/plugins/cloudbees/CloudbeesPublisher.java
@@ -76,12 +76,17 @@
@DataBoundConstructor
public CloudbeesPublisher(String accountName, String applicationId, String filePattern)
throws Exception {
System.out.println( "new CloudbeesPublisher" );
if (accountName == null) {
// revert to first one

CloudbeesAccount[] accounts = DESCRIPTOR.getAccounts();

if (accounts.length > 0) {
if (accounts != null && accounts.length > 0) {
accountName = accounts[0].name;
} else
{
accountName = "";
}
}
this.accountName = accountName;
@@ -92,11 +97,16 @@ public CloudbeesPublisher(String accountName, String applicationId, String fileP
}

public CloudbeesAccount getCloudbeesAccount() {
System.out.println( "getCloudbeesAccount" );
CloudbeesAccount[] accounts = DESCRIPTOR.getAccounts();
if (accountName == null && accounts.length > 0) {
// return default
return accounts[0];
if (accounts != null) {
return accounts[0];
}
return null;
}

for (CloudbeesAccount account : accounts) {
if (account.name.equals(accountName)) {
return account;
@@ -311,7 +321,7 @@ public void setAccounts(CloudbeesAccount cloudbeesAccount) {
}

public CloudbeesAccount[] getAccounts() {
return accounts.toArray(new CloudbeesAccount[0]);
return accounts.toArray(new CloudbeesAccount[accounts.size()]);
}

@Override

0 comments on commit 37157c3

Please sign in to comment.
You can’t perform that action at this time.