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

Added AzureRmWebAppDeploymentV5 to support OneDeploy for Linux App Service #20703

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ Tasks/AzureRmWebAppDeploymentV3/ @jvano @dannysongg @microsoft/azure-app-servi

Tasks/AzureRmWebAppDeploymentV4/ @jvano @dannysongg @microsoft/azure-app-service-pipelines-tasks @microsoft/release-management-task-team @manolerazvan

Tasks/AzureRmWebAppDeploymentV5/ @jvano @dannysongg @shilpirachna1 @microsoft/azure-app-service-pipelines-tasks @microsoft/release-management-task-team @manolerazvan

# DRI rotation: Azure Spring Apps/AzDMSS-Support
Tasks/AzureSpringCloudV0 @microsoft/azure-spring-apps @ruoyuwang @menxiao

Expand Down
3 changes: 3 additions & 0 deletions Tasks/AzureRmWebAppDeploymentV5/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
registry=https://pkgs.dev.azure.com/mseng/PipelineTools/_packaging/PipelineTools_PublicPackages/npm/registry/

always-auth=true
213 changes: 213 additions & 0 deletions Tasks/AzureRmWebAppDeploymentV5/README.md

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Tasks/AzureRmWebAppDeploymentV5/Tests/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
registry=https://pkgs.dev.azure.com/mseng/PipelineTools/_packaging/PipelineTools_PublicPackages/npm/registry/

always-auth=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import tl = require('azure-pipelines-task-lib');
import { AzureRmWebAppDeploymentProvider } from '../deploymentProvider/AzureRmWebAppDeploymentProvider'
import { TaskParametersUtility, TaskParameters } from '../operations/TaskParameters';
import { getMockEndpoint } from '../node_modules/azure-pipelines-tasks-azure-arm-rest/Tests/mock_utils';
import { mockAzureARMPreDeploymentSteps } from "./mock_utils";

getMockEndpoint();
mockAzureARMPreDeploymentSteps();

export class AzureRmWebAppDeploymentProviderL0Tests {

public static async startAzureRmWebAppDeploymentProviderL0Tests() {
await AzureRmWebAppDeploymentProviderL0Tests.testForPreDeploymentSteps();
await AzureRmWebAppDeploymentProviderL0Tests.testForPreDeploymentStepsWithSlotEnabled();
await AzureRmWebAppDeploymentProviderL0Tests.testForVirtualApplication();
await AzureRmWebAppDeploymentProviderL0Tests.testForUpdateDeploymentStatus();
}

public static async testForPreDeploymentSteps() {
try {
var taskParameters: TaskParameters = TaskParametersUtility.getParameters();
var azureRmWebAppDeploymentProvider : AzureRmWebAppDeploymentProvider = new AzureRmWebAppDeploymentProvider(taskParameters);
await azureRmWebAppDeploymentProvider.PreDeploymentStep();
} catch(error) {
tl.setResult(tl.TaskResult.Failed, 'PreDeployment steps should succeeded but failed with error');
}
}

public static async testForPreDeploymentStepsWithSlotEnabled() {
try {
var taskParameters: TaskParameters = TaskParametersUtility.getParameters();
taskParameters.DeployToSlotOrASEFlag = true;
taskParameters.ResourceGroupName = "MOCK_RESOURCE_GROUP_NAME";
var azureRmWebAppDeploymentProvider : AzureRmWebAppDeploymentProvider = new AzureRmWebAppDeploymentProvider(taskParameters);
await azureRmWebAppDeploymentProvider.PreDeploymentStep();
tl.setResult(tl.TaskResult.Succeeded, 'PreDeployment steps with slot enabled should succeeded');
} catch(error) {
tl.setResult(tl.TaskResult.Failed, 'PreDeployment steps with slot enabled failed with error');
}
}

public static async testForVirtualApplication() {
try {
var taskParameters: TaskParameters = TaskParametersUtility.getParameters();
taskParameters.DeployToSlotOrASEFlag = true;
taskParameters.ResourceGroupName = "MOCK_RESOURCE_GROUP_NAME";
taskParameters.VirtualApplication = "VirtualApplication";
var azureRmWebAppDeploymentProvider : AzureRmWebAppDeploymentProvider = new AzureRmWebAppDeploymentProvider(taskParameters);
await azureRmWebAppDeploymentProvider.PreDeploymentStep();
tl.setResult(tl.TaskResult.Succeeded, 'PreDeployment steps with virtual application should succeeded');
} catch(error) {
tl.setResult(tl.TaskResult.Failed, 'PreDeployment steps with virtual application failed with error');
}
}

public static async testForUpdateDeploymentStatus() {
try {
var taskParameters: TaskParameters = TaskParametersUtility.getParameters();
var azureRmWebAppDeploymentProvider : AzureRmWebAppDeploymentProvider = new AzureRmWebAppDeploymentProvider(taskParameters);
await azureRmWebAppDeploymentProvider.PreDeploymentStep();
await azureRmWebAppDeploymentProvider.UpdateDeploymentStatus(true);
} catch(error) {
tl.setResult(tl.TaskResult.Failed, 'UpdateDeploymentStatus steps should succeeded but failed with error');
}
}

}

AzureRmWebAppDeploymentProviderL0Tests.startAzureRmWebAppDeploymentProviderL0Tests();
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import tl = require('azure-pipelines-task-lib');
import tmrm = require('azure-pipelines-task-lib/mock-run');
import ma = require('azure-pipelines-task-lib/mock-answer');
import * as path from 'path';
import { setEndpointData, setAgentsData, mockTaskArgument, mockTaskInputParameters } from './utils';

export class AzureRmWebAppDeploymentProviderTests {

public static startAzureRmWebAppDeploymentProviderTests(){
let tp = path.join(__dirname, 'AzureRmWebAppDeploymentProviderL0Tests.js');
let tr : tmrm.TaskMockRunner = new tmrm.TaskMockRunner(tp);
mockTaskInputParameters(tr);
setEndpointData();
setAgentsData();

const kudu = {
updateDeployment : function(_) {
return "MOCK_DEPLOYMENT_ID";
}
};

const utility = {
getKuduService: function()
{
return Promise.resolve(kudu);
}
};

tr.registerMock('azure-pipelines-tasks-azure-arm-rest/azureAppServiceUtility', {
AzureAppServiceUtility: function(_) {
return utility;
}
});

tr.setAnswers(mockTaskArgument());
tr.run();
}

}

AzureRmWebAppDeploymentProviderTests.startAzureRmWebAppDeploymentProviderTests();
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import tl = require('azure-pipelines-task-lib');
import { BuiltInLinuxWebAppDeploymentProvider } from '../deploymentProvider/BuiltInLinuxWebAppDeploymentProvider'
import { TaskParametersUtility, TaskParameters } from '../operations/TaskParameters';
import { PackageType } from 'azure-pipelines-tasks-webdeployment-common/packageUtility';
import { getMockEndpoint } from '../node_modules/azure-pipelines-tasks-azure-arm-rest/Tests/mock_utils';
import { mockAzureARMPreDeploymentSteps, mockLinuxAppSettings } from "./mock_utils";

getMockEndpoint();
mockAzureARMPreDeploymentSteps();
mockLinuxAppSettings();

export class BuiltInLinuxWebAppDeploymentProviderL0Tests {

public static async startBuiltInLinuxWebAppDeploymentProviderL0Tests() {
await BuiltInLinuxWebAppDeploymentProviderL0Tests.testForPreDeploymentSteps_BuiltInLinuxWebApp();
await BuiltInLinuxWebAppDeploymentProviderL0Tests.testForPreDeploymentStepsWithSlotEnabled_BuiltInLinuxWebApp();
await BuiltInLinuxWebAppDeploymentProviderL0Tests.testForUpdateDeploymentStatus_BuiltInLinuxWebApp();
await BuiltInLinuxWebAppDeploymentProviderL0Tests.testForDeployWebAppStep_BuiltInLinuxWebApp_ZipPackage();
await BuiltInLinuxWebAppDeploymentProviderL0Tests.testForDeployWebAppStep_BuiltInLinuxWebApp_FolderPackage();
await BuiltInLinuxWebAppDeploymentProviderL0Tests.testForDeployWebAppStep_BuiltInLinuxWebApp_WarPackage();
await BuiltInLinuxWebAppDeploymentProviderL0Tests.testForDeployWebAppStep_BuiltInLinuxWebApp_JarPackage();
}

public static async testForPreDeploymentSteps_BuiltInLinuxWebApp() {
try {
var taskParameters: TaskParameters = TaskParametersUtility.getParameters();
var builtInLinuxWebAppDeploymentProvider : BuiltInLinuxWebAppDeploymentProvider = new BuiltInLinuxWebAppDeploymentProvider(taskParameters);
await builtInLinuxWebAppDeploymentProvider.PreDeploymentStep();
tl.setResult(tl.TaskResult.Succeeded, 'PreDeployment steps for built in linux web app should succeeded');
} catch(error) {
tl.setResult(tl.TaskResult.Failed, 'PreDeployment steps for built in linux web app failed with error');
}
}

public static async testForPreDeploymentStepsWithSlotEnabled_BuiltInLinuxWebApp() {
try {
var taskParameters: TaskParameters = TaskParametersUtility.getParameters();
taskParameters.DeployToSlotOrASEFlag = true;
taskParameters.ResourceGroupName = "MOCK_RESOURCE_GROUP_NAME";
var builtInLinuxWebAppDeploymentProvider : BuiltInLinuxWebAppDeploymentProvider = new BuiltInLinuxWebAppDeploymentProvider(taskParameters);
await builtInLinuxWebAppDeploymentProvider.PreDeploymentStep();
tl.setResult(tl.TaskResult.Succeeded, 'PreDeployment steps for built in linux web app with slot enabled should succeeded');
} catch(error) {
tl.setResult(tl.TaskResult.Failed, 'PreDeployment steps for built in linux web app with slot enabled failed with error');
}
}

public static async testForUpdateDeploymentStatus_BuiltInLinuxWebApp() {
try {
var taskParameters: TaskParameters = TaskParametersUtility.getParameters();
var builtInLinuxWebAppDeploymentProvider : BuiltInLinuxWebAppDeploymentProvider = new BuiltInLinuxWebAppDeploymentProvider(taskParameters);
await builtInLinuxWebAppDeploymentProvider.PreDeploymentStep();
await builtInLinuxWebAppDeploymentProvider.UpdateDeploymentStatus(true);
} catch(error) {
tl.setResult(tl.TaskResult.Failed, 'UpdateDeploymentStatus for built in linux web app steps should succeeded but failed with error');
}
}

public static async testForDeployWebAppStep_BuiltInLinuxWebApp_ZipPackage() {
try {
var taskParameters: TaskParameters = TaskParametersUtility.getParameters();
var builtInLinuxWebAppDeploymentProvider : BuiltInLinuxWebAppDeploymentProvider = new BuiltInLinuxWebAppDeploymentProvider(taskParameters);
await builtInLinuxWebAppDeploymentProvider.PreDeploymentStep();
await builtInLinuxWebAppDeploymentProvider.DeployWebAppStep();
tl.setResult(tl.TaskResult.Succeeded, 'DeployWebAppStep for built in linux web app steps with zip package succeeded');
} catch(error) {
tl.setResult(tl.TaskResult.Failed, 'DeployWebAppStep for built in linux web app steps with zip package should succeeded but failed with error');
}
}

public static async testForDeployWebAppStep_BuiltInLinuxWebApp_FolderPackage() {
try {
var taskParameters: TaskParameters = TaskParametersUtility.getParameters();
taskParameters.Package.getPackageType = () :PackageType => {return PackageType.folder};
taskParameters.Package.getPath = () :string => { return "webAppPkg" };
var builtInLinuxWebAppDeploymentProvider : BuiltInLinuxWebAppDeploymentProvider = new BuiltInLinuxWebAppDeploymentProvider(taskParameters);
await builtInLinuxWebAppDeploymentProvider.PreDeploymentStep();
await builtInLinuxWebAppDeploymentProvider.DeployWebAppStep();
tl.setResult(tl.TaskResult.Succeeded, 'DeployWebAppStep for built in linux web app steps with folder package succeeded');
} catch(error) {
tl.setResult(tl.TaskResult.Failed, 'DeployWebAppStep for built in linux web app steps with folder package should succeeded but failed with error');
}
}

public static async testForDeployWebAppStep_BuiltInLinuxWebApp_WarPackage() {
try {
var taskParameters: TaskParameters = TaskParametersUtility.getParameters();
taskParameters.Package.getPackageType = () :PackageType => {return PackageType.war};
taskParameters.Package.getPath = () :string => { return "webAppPkg.war" };
var builtInLinuxWebAppDeploymentProvider : BuiltInLinuxWebAppDeploymentProvider = new BuiltInLinuxWebAppDeploymentProvider(taskParameters);
await builtInLinuxWebAppDeploymentProvider.PreDeploymentStep();
await builtInLinuxWebAppDeploymentProvider.DeployWebAppStep();
tl.setResult(tl.TaskResult.Succeeded, 'DeployWebAppStep for built in linux web app steps with war package succeeded');
} catch(error) {
tl.setResult(tl.TaskResult.Failed, 'DeployWebAppStep for built in linux web app steps with war package should succeeded but failed with error');
}
}

public static async testForDeployWebAppStep_BuiltInLinuxWebApp_JarPackage() {
try {
var taskParameters: TaskParameters = TaskParametersUtility.getParameters();
taskParameters.Package.getPackageType = () :PackageType => {return PackageType.jar};
taskParameters.Package.getPath = () :string => { return "webAppPkg.jar" };
var builtInLinuxWebAppDeploymentProvider : BuiltInLinuxWebAppDeploymentProvider = new BuiltInLinuxWebAppDeploymentProvider(taskParameters);
await builtInLinuxWebAppDeploymentProvider.PreDeploymentStep();
await builtInLinuxWebAppDeploymentProvider.DeployWebAppStep();
tl.setResult(tl.TaskResult.Succeeded, 'DeployWebAppStep for built in linux web app steps with jar package succeeded');
} catch(error) {
tl.setResult(tl.TaskResult.Failed, 'DeployWebAppStep for built in linux web app steps with jar package should succeeded but failed with error');
}
}

}

BuiltInLinuxWebAppDeploymentProviderL0Tests.startBuiltInLinuxWebAppDeploymentProviderL0Tests();
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import tmrm = require('azure-pipelines-task-lib/mock-run');
import * as path from 'path';
import { setEndpointData, setAgentsData, mockTaskArgument, mockTaskInputParameters } from './utils';

export class BuiltInLinuxWebAppDeploymentProviderTests {

public static startBuiltInLinuxWebAppDeploymentProviderTests(){
let tp = path.join(__dirname, 'BuiltInLinuxWebAppDeploymentProviderL0Tests.js');
let tr : tmrm.TaskMockRunner = new tmrm.TaskMockRunner(tp);
mockTaskInputParameters(tr);
setEndpointData();
setAgentsData();


const kudu = {
updateDeployment : function(D) {
return "MOCK_DEPLOYMENT_ID";
},
getAppSettings : function() {
var map: Map<string, string> = new Map<string, string>();
map.set('MSDEPLOY_RENAME_LOCKED_FILES', '1');
map.set('ScmType', 'ScmType');
return map;
},
zipDeploy: function(E, F) {
return '{id: "ZIP_DEPLOY_FAILED_ID", status: 3, deployer: "VSTS_ZIP_DEPLOY", author: "VSTS USER"}';
},
warDeploy: function(G, H) {
return '{id: "ZIP_DEPLOY_FAILED_ID", status: 3, deployer: "VSTS_ZIP_DEPLOY", author: "VSTS USER"}';
},
getDeploymentDetails: function(I) {
return "{ type: 'Deployment',url: 'http://MOCK_SCM_WEBSITE/api/deployments/MOCK_DEPLOYMENT_ID'}";
}
};

const utility = {
getKuduService: function()
{
return Promise.resolve(kudu);
}
};

tr.registerMock('azure-pipelines-tasks-azure-arm-rest/azureAppServiceUtility', {
AzureAppServiceUtility: function(_) {
return utility;
}
});

tr.registerMock('azure-pipelines-tasks-webdeployment-common/utility.js', {
generateTemporaryFolderForDeployment: function () {
return "webAppPkg";
},
archiveFolderForDeployment: function() {
return {
"webDeployPkg": "webAppPkg",
"tempPackagePath": "webAppPkg"
};
},
getFileNameFromPath: function(A, B) {
return "webAppPkg";
},
generateTemporaryFolderOrZipPath: function(C, D) {
return "webAppPkg.zip";
}
});

tr.registerMock('azure-pipelines-tasks-webdeployment-common/ziputility.js', {
archiveFolder: function(A, B){
return "webAppPkg.zip";
}
});

tr.setAnswers(mockTaskArgument());
tr.run();
}


}

BuiltInLinuxWebAppDeploymentProviderTests.startBuiltInLinuxWebAppDeploymentProviderTests();
Loading