Skip to content

Commit

Permalink
add default params for MSDEPLOY (#6527)
Browse files Browse the repository at this point in the history
* add default params for MSDEPLOY

* fix L0 failure

* Update L0MSDeployUtility.ts

* changed let to var (node 5)

* fixed tests

* bump-up patch version

* added check for setparam file

* addressed review comments

* formatting fix

* Update L0.ts
  • Loading branch information
vincent1173 authored Mar 5, 2018
1 parent b4439a6 commit c3551bf
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 11 deletions.
15 changes: 15 additions & 0 deletions Tasks/AzureRmWebAppDeployment/Tests/L0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ describe('AzureRmWebAppDeployment Suite', function() {
assert(ltx.equal(resultFile, expectFile) , 'Should Transform attributes on Web.config');
done();
});

it('Validate MSDeploy parameters', (done:MochaDone) => {
let tp = path.join(__dirname, "..", "node_modules","webdeployment-common","Tests","L0MSDeployUtility.js");
let tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);
tr.run();

assert(tr.stdout.search('MSBUILD DEFAULT PARAMS PASSED') > 0, 'should have printed MSBUILD DEFAULT PARAMS PASSED');
assert(tr.stdout.search('ARGUMENTS WITH SET PARAMS PASSED') > 0, 'should have printed ARGUMENTS WITH SET PARAMS PASSED');
assert(tr.stdout.search('ARGUMENT WITH FOLDER PACKAGE PASSED') > 0, 'should have printed ARGUMENT WITH FOLDER PACKAGE PASSED');
assert(tr.stdout.search('ARGUMENT WITH EXCLUDE APP DATA PASSED') > 0, 'should have printed ARGUMENT WITH EXCLUDE APP DATA PASSED');
assert(tr.stdout.search('ARGUMENT WITH WAR PACKAGE PASSED') > 0, 'should have printed ARGUMENT WITH WAR PACKAGE PASSED');
assert(tr.stdout.search('ARGUMENT WITH OVERRIDE RETRY FLAG PASSED') > 0, 'should have printed ARGUMENT WITH OVERRIDE RETRY FLAG PASSED');

done();
});
}
else {

Expand Down
6 changes: 5 additions & 1 deletion Tasks/AzureRmWebAppDeployment/operations/TaskParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ export class TaskParametersUtility {
taskParameters.RemoveAdditionalFilesFlag = tl.getBoolInput('RemoveAdditionalFilesFlag', false);
taskParameters.SetParametersFile = tl.getPathInput('SetParametersFile', false);
taskParameters.ExcludeFilesFromAppDataFlag = tl.getBoolInput('ExcludeFilesFromAppDataFlag', false)
taskParameters.AdditionalArguments = tl.getInput('AdditionalArguments', false);
taskParameters.AdditionalArguments = tl.getInput('AdditionalArguments', false) || '';
}
else {
// Retry Attempt is passed by default
taskParameters.AdditionalArguments = '-retryAttempts:6 -retryInterval:10000';
}

return taskParameters;
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureRmWebAppDeployment/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@
"type": "string",
"label": "Additional arguments",
"required": false,
"defaultValue": "",
"defaultValue": "-retryAttempts:6 -retryInterval:10000",
"groupName": "AdditionalDeploymentOptions",
"visibleRule": "UseWebDeploy == true",
"helpMarkDown": "Additional Web Deploy arguments following the syntax -key:value .<br />These will be applied when deploying the Azure App Service. Example: -disableLink:AppPoolExtension -disableLink:ContentExtension.<br />For more examples of Web Deploy operation settings, refer to [this](https://go.microsoft.com/fwlink/?linkid=838471)."
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureRmWebAppDeployment/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@
"type": "string",
"label": "ms-resource:loc.input.label.AdditionalArguments",
"required": false,
"defaultValue": "",
"defaultValue": "-retryAttempts:6 -retryInterval:10000",
"groupName": "AdditionalDeploymentOptions",
"visibleRule": "UseWebDeploy == true",
"helpMarkDown": "ms-resource:loc.input.help.AdditionalArguments"
Expand Down
99 changes: 99 additions & 0 deletions Tasks/Common/webdeployment-common/Tests/L0MSDeployUtility.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
var msdeployUtility = require('webdeployment-common/msdeployutility.js');

function checkParametersIfPresent(argumentString: string, argumentCheckArray: Array<string>) {
for(var argument of argumentCheckArray) {
if(argumentString.indexOf(argument) == -1) {
return false;
}
}

return true;
}

var defaultMSBuildPackageArgument: string = msdeployUtility.getMSDeployCmdArgs('package.zip', 'webapp_name', {
publishUrl: 'http://webapp_name.scm.azurewebsites.net:443', userName: '$webapp_name', userPWD: 'webapp_password'
}, true, false, true, null, null, null, true, false, false);

console.log(` * MSBUILD DEFAULT PARAMS: ${defaultMSBuildPackageArgument}`);
if(checkParametersIfPresent(defaultMSBuildPackageArgument, ["-source:package=\"'package.zip'\"",
" -dest:auto,ComputerName=\"'https://http://webapp_name.scm.azurewebsites.net:443/msdeploy.axd?site=webapp_name'\",UserName=\"'$webapp_name'\",Password=\"'webapp_password'\",AuthType=\"'Basic'\"",
" -setParam:name=\"'IIS Web Application Name'\",value=\"'webapp_name'\"", '-enableRule:AppOffline']) && defaultMSBuildPackageArgument.indexOf('-setParamFile') == -1) {
console.log("MSBUILD DEFAULT PARAMS PASSED");
}
else {
throw new Error('MSBUILD PACKAGE DEFAULT PARAMS FAILED');
}


var packageWithSetParamArgument: string = msdeployUtility.getMSDeployCmdArgs('package.zip', 'webapp_name', {
publishUrl: 'http://webapp_name.scm.azurewebsites.net:443', userName: '$webapp_name', userPWD: 'webapp_password'
}, false, false, true, null, 'temp_param.xml', null, false, false, true);


console.log(` * PACKAGE WITh SET PARAMS: ${packageWithSetParamArgument}`);


if(checkParametersIfPresent(packageWithSetParamArgument, ['-setParamFile=temp_param.xml', "-dest:contentPath=\"'webapp_name'\"" , '-enableRule:DoNotDelete'])) {
console.log('ARGUMENTS WITH SET PARAMS PASSED');
}
else {
throw Error('ARGUMENTS WITH SET PARAMS FAILED');
}

var folderPackageArgument: string = msdeployUtility.getMSDeployCmdArgs('c:/package/folder', 'webapp_name', {
publishUrl: 'http://webapp_name.scm.azurewebsites.net:443', userName: '$webapp_name', userPWD: 'webapp_password'
}, true, false, true, null, null, null, true, true, true);

console.log(` * ARGUMENT WITh FOLDER AS PACKAGE: ${folderPackageArgument}`);
if(checkParametersIfPresent(folderPackageArgument, [
"-source:IisApp=\"'c:/package/folder'\"",
" -dest:iisApp=\"'webapp_name'\""
])) {
console.log('ARGUMENT WITH FOLDER PACKAGE PASSED');
}
else {
throw Error('ARGUMENT WITH FOLDER PACKAGE FAILED');
}


var packageWithExcludeAppDataArgument: string = msdeployUtility.getMSDeployCmdArgs('package.zip', 'webapp_name', {
publishUrl: 'http://webapp_name.scm.azurewebsites.net:443', userName: '$webapp_name', userPWD: 'webapp_password'
}, false, true, true, null, null, null, false, false, true);

console.log(` * ARGUMENT WITh FOLDER AS PACKAGE: ${packageWithExcludeAppDataArgument}`);

if(checkParametersIfPresent(packageWithExcludeAppDataArgument, ['-skip:Directory=App_Data'])) {
console.log('ARGUMENT WITH EXCLUDE APP DATA PASSED');
}
else {
throw new Error('ARGUMENT WITH EXCLUDE APP DATA FAILED');
}


var warDeploymentArgument: string = msdeployUtility.getMSDeployCmdArgs('package.war', 'webapp_name', {
publishUrl: 'http://webapp_name.scm.azurewebsites.net:443', userName: '$webapp_name', userPWD: 'webapp_password'
}, false, true, true, null, null, null, false, false, true);

console.log(` * ARGUMENT WITh WAR FILE AS PACKAGE: ${warDeploymentArgument}`);
if(checkParametersIfPresent(warDeploymentArgument, [
" -source:contentPath=\"'package.war'\"",
" -dest:contentPath=\"'/site/webapps/package.war'\""
])) {
console.log('ARGUMENT WITH WAR PACKAGE PASSED');
}
else {
throw new Error('ARGUMENT WITH WAR PACKAGE FAILED');
}

var overrideRetryArgument: string = msdeployUtility.getMSDeployCmdArgs('package.zip', 'webapp_name', {
publishUrl: 'http://webapp_name.scm.azurewebsites.net:443', userName: '$webapp_name', userPWD: 'webapp_password'
}, false, true, true, null, null, '-retryAttempts:11 -retryInterval:5000', false, false, true);

console.log(` * ARGUMENTS WITH WAR FILE: ${overrideRetryArgument}`);

if(checkParametersIfPresent(overrideRetryArgument, ['-retryAttempts:11', '-retryInterval:5000'])) {
console.log('ARGUMENT WITH OVERRIDE RETRY FLAG PASSED');
}
else {
throw new Error('ARGUMENT WITH OVERRIDE RETRY FLAG FAILED');
}
7 changes: 3 additions & 4 deletions Tasks/Common/webdeployment-common/msdeployutility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,11 @@ export function getMSDeployCmdArgs(webAppPackage: string, webAppName: string, pu
if(excludeFilesFromAppDataFlag) {
msDeployCmdArgs += ' -skip:Directory=App_Data';
}

if(additionalArguments) {
msDeployCmdArgs += ' ' + additionalArguments;
}
}

additionalArguments = additionalArguments ? additionalArguments : ' ';
msDeployCmdArgs += ' ' + additionalArguments;

if(!(removeAdditionalFilesFlag && useWebDeploy)) {
msDeployCmdArgs += " -enableRule:DoNotDeleteRule";
}
Expand Down
22 changes: 18 additions & 4 deletions Tasks/IISWebAppDeploymentOnMachineGroup/Tests/L0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ describe('IISWebsiteDeploymentOnMachineGroup test suite', function() {
let tp = path.join(__dirname, 'L0WindowsFailDefault.js');
let tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);

tr.run();

var expectedErr = 'Error: msdeploy failed with return code: 1';
tr.run();
var expectedErr = 'Error: msdeploy failed with return code: 1';
assert(tr.invokedToolCount == 3, 'should have invoked tool thrice despite failure');
assert(tr.errorIssues.length > 0 || tr.stderr.length > 0, 'should have written to stderr');
assert(tr.stdErrContained(expectedErr) || tr.createdErrorIssue(expectedErr), 'E should have said: ' + expectedErr);
Expand Down Expand Up @@ -96,7 +96,7 @@ describe('IISWebsiteDeploymentOnMachineGroup test suite', function() {
let tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);

tr.run();
assert(tr.invokedToolCount == 0, 'should not have invoked any tool');
assert(tr.invokedToolCount == 0, 'should not have invoked any tool');
assert(tr.stderr.length > 0 || tr.errorIssues.length > 0, 'should have written to stderr');
var expectedErr = 'Error: loc_mock_MorethanonepackagematchedwithspecifiedpatternPleaserestrainthesearchpattern';
assert(tr.stdErrContained(expectedErr) || tr.createdErrorIssue(expectedErr), 'should have said: ' + expectedErr);
Expand Down Expand Up @@ -226,4 +226,18 @@ describe('IISWebsiteDeploymentOnMachineGroup test suite', function() {
assert(tr.stdout.search('## mkdir Successful ##') >= 0, 'should have created dir including dest folder');
done();
});

it('Validate MSDeploy parameters', (done:MochaDone) => {
let tp = path.join(__dirname, "..", "node_modules","webdeployment-common","Tests","L0MSDeployUtility.js");
let tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);
tr.run();

assert(tr.stdout.search('MSBUILD DEFAULT PARAMS PASSED') > 0, 'should have printed MSBUILD DEFAULT PARAMS PASSED');
assert(tr.stdout.search('ARGUMENTS WITH SET PARAMS PASSED') > 0, 'should have printed ARGUMENTS WITH SET PARAMS PASSED');
assert(tr.stdout.search('ARGUMENT WITH FOLDER PACKAGE PASSED') > 0, 'should have printed ARGUMENT WITH FOLDER PACKAGE PASSED');
assert(tr.stdout.search('ARGUMENT WITH EXCLUDE APP DATA PASSED') > 0, 'should have printed ARGUMENT WITH EXCLUDE APP DATA PASSED');
assert(tr.stdout.search('ARGUMENT WITH WAR PACKAGE PASSED') > 0, 'should have printed ARGUMENT WITH WAR PACKAGE PASSED');
assert(tr.stdout.search('ARGUMENT WITH OVERRIDE RETRY FLAG PASSED') > 0, 'should have printed ARGUMENT WITH OVERRIDE RETRY FLAG PASSED');
done();
});
});

0 comments on commit c3551bf

Please sign in to comment.