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

add default params for MSDEPLOY #6527

Merged
merged 12 commits into from
Mar 5, 2018
16 changes: 16 additions & 0 deletions Tasks/AzureRmWebAppDeployment/Tests/L0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ 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('MSDEPLOY ARGUMENT RETRY FLAG PASSED') > 0, 'should have printed MSDEPLOY ARGUMENT RETRY FLAG 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
2 changes: 1 addition & 1 deletion Tasks/AzureRmWebAppDeployment/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": {
"Major": 3,
"Minor": 3,
"Patch": 42
"Patch": 43
},
"releaseNotes": "What's new in Version 3.0: <br/>&nbsp;&nbsp;Supports File Transformations (XDT) <br/>&nbsp;&nbsp;Supports Variable Substitutions(XML, JSON) <br/>Click [here](https://aka.ms/azurermwebdeployreadme) for more Information.",
"minimumAgentVersion": "2.104.1",
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 @@ -16,7 +16,7 @@
"version": {
"Major": 3,
"Minor": 3,
"Patch": 42
"Patch": 43
},
"releaseNotes": "ms-resource:loc.releaseNotes",
"minimumAgentVersion": "2.104.1",
Expand Down
107 changes: 107 additions & 0 deletions Tasks/Common/webdeployment-common/Tests/L0MSDeployUtility.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
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, true);

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'])) {
console.log("MSBUILD DEFAULT PARAMS PASSED");
}
else {
throw new Error('MSBUILD PACKAGE DEFAULT PARAMS FAILED');
}


if(checkParametersIfPresent(defaultMSBuildPackageArgument, ['-retryAttempts:6', '-retryInterval:10000'])) {
console.log('MSDEPLOY ARGUMENT RETRY FLAG PASSED');
}
else {
throw new Error('MSBUILD DEFAULT PARAMS FAILED: RETRY FLAG MISMATCH');
}


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');
}
10 changes: 6 additions & 4 deletions Tasks/Common/webdeployment-common/msdeployutility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@ export function getMSDeployCmdArgs(webAppPackage: string, webAppName: string, pu
if(excludeFilesFromAppDataFlag) {
msDeployCmdArgs += ' -skip:Directory=App_Data';
}

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

additionalArguments = !!(additionalArguments) ? additionalArguments : ' ';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of all these, why can't we just add the default values in the task.json for "additionalArguments" input? The task code will handle them as just another additional arguments input. This will be transparent as user know the values with which msdeploy is being run. User has flexibility to update the default values if required.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the value based on the discussion.

additionalArguments = additionalArguments.indexOf('-retryAttempts') != -1 ? additionalArguments : additionalArguments.concat(' -retryAttempts:6');
additionalArguments = additionalArguments.indexOf('-retryInterval') != -1 ? additionalArguments : additionalArguments.concat(' -retryInterval:10000');

msDeployCmdArgs += ' ' + additionalArguments;

if(!(removeAdditionalFilesFlag && useWebDeploy)) {
msDeployCmdArgs += " -enableRule:DoNotDeleteRule";
}
Expand Down
15 changes: 15 additions & 0 deletions Tasks/IISWebAppDeploymentOnMachineGroup/Tests/L0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,19 @@ 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('MSDEPLOY ARGUMENT RETRY FLAG PASSED') > 0, 'should have printed MSDEPLOY ARGUMENT RETRY FLAG 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();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let a: any = <any>{
"msdeploy": true
},
"exec": {
"msdeploy -verb:sync -source:package='webAppPkg.zip' -dest:auto -setParam:name='IIS Web Application Name',value='mytestwebsite' -enableRule:DoNotDeleteRule": {
"msdeploy -verb:sync -source:package='webAppPkg.zip' -dest:auto -setParam:name='IIS Web Application Name',value='mytestwebsite' -retryAttempts:6 -retryInterval:10000 -enableRule:DoNotDeleteRule": {
"code": 1,
"stdout": "Failed to execute command"
},
Expand Down
3 changes: 1 addition & 2 deletions Tasks/IISWebAppDeploymentOnMachineGroup/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Tasks/IISWebAppDeploymentOnMachineGroup/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 0,
"Minor": 0,
"Patch": 34
"Patch": 35
},
"demands": [],
"minimumAgentVersion": "2.104.1",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/IISWebAppDeploymentOnMachineGroup/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 0,
"Minor": 0,
"Patch": 34
"Patch": 35
},
"demands": [],
"minimumAgentVersion": "2.104.1",
Expand Down