in src/main/java/com/microsoft/jenkins/appservice/WebAppDeploymentRecorder.java [222:271]
public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath workspace, @Nonnull Launcher launcher, @Nonnull TaskListener listener)
throws InterruptedException, IOException {
// Only deploy on build succeeds
// Also check if result is null here because in pipeline web app deploy is not run as a post-build action.
// In this case result is null and pipeline will stop if previous step failed. So no need to check result in this case.
if (run.getResult() != null && run.getResult() != Result.SUCCESS && deployOnlyIfSuccessful) {
listener.getLogger().println("Deploy to Azure Web App is skipped due to previous steps failed.");
return;
}
listener.getLogger().println("Starting Azure Web App Deployment");
// Get app info
final Azure azureClient = TokenCache.getInstance(AzureCredentials.getServicePrincipal(azureCredentialsId)).getAzureClient();
final WebApp app = azureClient.webApps().getByResourceGroup(resourceGroup, appName);
if (app == null) {
throw new AbortException(String.format("Web App %s in resource group %s not found", appName, resourceGroup));
}
final String expandedFilePath = run.getEnvironment(listener).expand(filePath);
final DockerBuildInfo dockerBuildInfo;
try {
dockerBuildInfo = validateDockerBuildInfo(run, listener, app);
} catch (AzureCloudException e) {
throw new AbortException(e.getMessage());
}
final WebAppDeploymentCommandContext commandContext = new WebAppDeploymentCommandContext(expandedFilePath);
commandContext.setSourceDirectory(sourceDirectory);
commandContext.setTargetDirectory(targetDirectory);
commandContext.setSlotName(slotName);
commandContext.setPublishType(publishType);
commandContext.setDockerBuildInfo(dockerBuildInfo);
commandContext.setDeleteTempImage(deleteTempImage);
commandContext.setAzureCredentialsId(azureCredentialsId);
try {
commandContext.configure(run, workspace, listener, app);
} catch (AzureCloudException e) {
throw new AbortException(e.getMessage());
}
CommandService.executeCommands(commandContext);
if (!commandContext.getHasError()) {
listener.getLogger().println("Done Azure Web App deployment.");
} else {
throw new AbortException("Azue Web App deployment failed.");
}
}