|
79 | 79 | import java.util.logging.Logger; |
80 | 80 | import java.util.stream.Collectors; |
81 | 81 |
|
| 82 | +import static hudson.Util.fixEmpty; |
| 83 | +import static java.util.Objects.requireNonNull; |
| 84 | + |
82 | 85 | /** |
83 | 86 | * Business delegate class which handles calls to Azure management service SDK. |
84 | 87 | * |
@@ -497,7 +500,11 @@ public AzureVMDeploymentInfo createDeployment( |
497 | 500 | // If using the custom script extension (vs. SSH) to startup the powershell scripts, |
498 | 501 | // add variables for that and upload the init script to the storage account |
499 | 502 | if (useCustomScriptExtension) { |
500 | | - putVariable(tmp, "jenkinsServerURL", Jenkins.get().getRootUrl()); |
| 503 | + String rootUrl = fixEmpty(Jenkins.get().getRootUrl()); |
| 504 | + if (rootUrl == null) { |
| 505 | + throw AzureCloudException.create("Jenkins URL must be set"); |
| 506 | + } |
| 507 | + putVariable(tmp, "jenkinsServerURL", rootUrl); |
501 | 508 | // Calculate the client secrets. The secrets are based off the machine name, |
502 | 509 | ArrayNode clientSecretsNode = ((ObjectNode) tmp.get("variables")).putArray("clientSecrets"); |
503 | 510 | for (int i = 0; i < numberOfAgents; i++) { |
@@ -584,9 +591,11 @@ public AzureVMDeploymentInfo createDeployment( |
584 | 591 | cloudName, template.getResourceGroupName(), deploymentName, scriptUri); |
585 | 592 | // Create the deployment |
586 | 593 |
|
| 594 | + String templateJson = tmp.toString(); |
| 595 | + LOGGER.log(Level.FINE, templateJson); |
587 | 596 | azureClient.deployments().define(deploymentName) |
588 | 597 | .withExistingResourceGroup(template.getResourceGroupName()) |
589 | | - .withTemplate(tmp.toString()) |
| 598 | + .withTemplate(templateJson) |
590 | 599 | .withParameters(parameters.toString()) |
591 | 600 | .withMode(DeploymentMode.INCREMENTAL) |
592 | 601 | .beginCreate(); |
|
0 commit comments