Skip to content

Commit

Permalink
[JENKINS-9556] configuring job without configuring any cloudbees acco…
Browse files Browse the repository at this point in the history
…unt throw a NPE
  • Loading branch information
olamy committed May 2, 2011
1 parent db46b81 commit 37157c3
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -76,12 +76,17 @@ public class CloudbeesPublisher extends Notifier {
@DataBoundConstructor @DataBoundConstructor
public CloudbeesPublisher(String accountName, String applicationId, String filePattern) public CloudbeesPublisher(String accountName, String applicationId, String filePattern)
throws Exception { throws Exception {
System.out.println( "new CloudbeesPublisher" );
if (accountName == null) { if (accountName == null) {
// revert to first one // revert to first one

CloudbeesAccount[] accounts = DESCRIPTOR.getAccounts(); CloudbeesAccount[] accounts = DESCRIPTOR.getAccounts();


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


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

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


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


@Override @Override
Expand Down

0 comments on commit 37157c3

Please sign in to comment.