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

Copying v5 changes to v4 for easier PR #20736

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"loc.releaseNotes": "What's new in version 4.*<br />Supports Zip Deploy, Run From Package, War Deploy [Details here](https://aka.ms/appServiceDeploymentMethods)<br />Supports App Service Environments<br />Improved UI for discovering different App service types supported by the task<br/>Run From Package is the preferred deployment method, which makes files in wwwroot folder read-only<br/>Click [here](https://aka.ms/azurermwebdeployreadme) for more information.",
"loc.group.displayName.FileTransformsAndVariableSubstitution": "File Transforms & Variable Substitution Options",
"loc.group.displayName.AdditionalDeploymentOptions": "Additional Deployment Options",
"loc.group.displayName.AdditionalDeploymentOptionsLinux": "Additional Deployment Options",
"loc.group.displayName.PostDeploymentAction": "Post Deployment Action",
"loc.group.displayName.ApplicationAndConfigurationSettings": "Application and Configuration Settings",
"loc.input.label.ConnectionType": "Connection type",
Expand Down Expand Up @@ -74,6 +75,10 @@
"loc.input.help.XmlVariableSubstitution": "Variables defined in the build or release pipelines will be matched against the 'key' or 'name' entries in the appSettings, applicationSettings, and connectionStrings sections of any config file and parameters.xml. Variable Substitution is run after config transforms. <br/><br/> Note: If same variables are defined in the release pipeline and in the environment, then the environment variables will supersede the release pipeline variables.<br/>",
"loc.input.label.JSONFiles": "JSON variable substitution",
"loc.input.help.JSONFiles": "Provide new line separated list of JSON files to substitute the variable values. Files names are to be provided relative to the root folder. <br/> To substitute JSON variables that are nested or hierarchical, specify them using JSONPath expressions. <br/> <br/> For example, to replace the value of ‘ConnectionString’ in the sample below, you need to define a variable as ‘Data.DefaultConnection.ConnectionString’ in the build or release pipeline (or release pipeline's environment). <br/> {<br/>&nbsp;&nbsp;\"Data\": {<br/>&nbsp;&nbsp;&nbsp;&nbsp;\"DefaultConnection\": {<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\"ConnectionString\": \"Server=(localdb)\\SQLEXPRESS;Database=MyDB;Trusted_Connection=True\"<br/>&nbsp;&nbsp;&nbsp;&nbsp;}<br/>&nbsp;&nbsp;}<br/> }<br/> Variable Substitution is run after configuration transforms. <br/><br/> Note: pipeline variables are excluded in substitution.",
"loc.input.label.DeploymentTypeLinux": "Deployment method",
"loc.input.help.DeploymentTypeLinux": "Choose the deployment method for the app.",
"loc.input.label.CleanDeploymentFlag": "Enable clean deployment",
"loc.input.help.CleanDeploymentFlag": "Deployment mode for complete sync (clean) deployment",
"loc.messages.Invalidwebapppackageorfolderpathprovided": "Invalid App Service package or folder path provided: %s",
"loc.messages.SetParamFilenotfound0": "Set parameters file not found: %s",
"loc.messages.XDTTransformationsappliedsuccessfully": "XML Transformations applied successfully",
Expand Down Expand Up @@ -204,6 +209,8 @@
"loc.messages.MultipleResourceGroupFoundForAppService": "Multiple resource group found for App Service '%s'.",
"loc.messages.PackageDeploymentUsingZipDeployFailed": "Package deployment using ZIP Deploy failed. Refer logs for more details.",
"loc.messages.PackageDeploymentInitiated": "Package deployment using ZIP Deploy initiated.",
"loc.messages.PackageDeploymentInitiatedWithOneDeploy": "Package deployment using One Deploy initiated.",
"loc.messages.OneDeployWithIncrementalDeploymentOption": "Deploying using incremental deployment.",
"loc.messages.WarPackageDeploymentInitiated": "Package deployment using WAR Deploy initiated.",
"loc.messages.FailedToGetDeploymentLogs": "Failed to get deployment logs. Error: %s",
"loc.messages.GoExeNameNotPresent": "Go exe name is not present",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import tl = require('azure-pipelines-task-lib/task');
import { PackageType } from 'azure-pipelines-tasks-webdeployment-common/packageUtility';
import path = require('path');
import * as ParameterParser from 'azure-pipelines-tasks-webdeployment-common/ParameterParserUtility';
import { DeploymentTypeLinux } from '../operations/TaskParameters';

var webCommonUtility = require('azure-pipelines-tasks-webdeployment-common/utility.js');
var deployUtility = require('azure-pipelines-tasks-webdeployment-common/utility.js');
Expand Down Expand Up @@ -52,19 +53,37 @@ export class BuiltInLinuxWebAppDeploymentProvider extends AzureRmWebAppDeploymen
if(!isNewValueUpdated) {
await this.kuduServiceUtility.warmpUp();
}

var zipDeploy: boolean = this.taskParams.DeploymentTypeLinux === DeploymentTypeLinux.zipDeploy;
var isClean: boolean = this.taskParams.CleanDeploymentFlag;
if (!zipDeploy && !isClean) {
console.log(tl.loc('OneDeployWithIncrementalDeploymentOption'));
}

switch(packageType){
case PackageType.folder:
let tempPackagePath = deployUtility.generateTemporaryFolderOrZipPath(tl.getVariable('AGENT.TEMPDIRECTORY'), false);
let archivedWebPackage = await zipUtility.archiveFolder(this.taskParams.Package.getPath(), "", tempPackagePath);
tl.debug("Compressed folder into zip " + archivedWebPackage);
this.zipDeploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(archivedWebPackage, this.taskParams.TakeAppOfflineFlag,
{ slotName: this.appService.getSlot() });
if (zipDeploy) {
this.zipDeploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(archivedWebPackage, this.taskParams.TakeAppOfflineFlag,
{ slotName: this.appService.getSlot() }, true);
}
else {
this.zipDeploymentID = await this.kuduServiceUtility.deployUsingOneDeploy(archivedWebPackage, isClean, this.taskParams.TakeAppOfflineFlag,
{ slotName: this.appService.getSlot() }, 'Zip', true);
}

break;
case PackageType.zip:
this.zipDeploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(this.taskParams.Package.getPath(), this.taskParams.TakeAppOfflineFlag,
{ slotName: this.appService.getSlot() });
if (zipDeploy) {
this.zipDeploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(this.taskParams.Package.getPath(), this.taskParams.TakeAppOfflineFlag,
{ slotName: this.appService.getSlot() }, true);
}
else {
this.zipDeploymentID = await this.kuduServiceUtility.deployUsingOneDeploy(this.taskParams.Package.getPath(), isClean, this.taskParams.TakeAppOfflineFlag,
{ slotName: this.appService.getSlot() }, 'Zip', true);
}

break;

Expand All @@ -74,8 +93,14 @@ export class BuiltInLinuxWebAppDeploymentProvider extends AzureRmWebAppDeploymen
var output = await webCommonUtility.archiveFolderForDeployment(false, folderPath);
var webPackage = output.webDeployPkg;
tl.debug("Initiated deployment via kudu service for webapp jar package : "+ webPackage);
this.zipDeploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(webPackage, this.taskParams.TakeAppOfflineFlag,
{ slotName: this.appService.getSlot() });
if (zipDeploy) {
this.zipDeploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(webPackage, this.taskParams.TakeAppOfflineFlag,
{ slotName: this.appService.getSlot() }, true);
}
else {
this.zipDeploymentID = await this.kuduServiceUtility.deployUsingOneDeploy(webPackage, isClean, this.taskParams.TakeAppOfflineFlag,
{ slotName: this.appService.getSlot() }, 'Jar', true);
}

break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const physicalRootPath: string = '/site/wwwroot';
const deploymentFolder: string = 'site/deployments';
const manifestFileName: string = 'manifest';
const VSTS_ZIP_DEPLOY: string = 'VSTS_ZIP_DEPLOY';
const VSTS_ONE_DEPLOY: string = 'VSTS_ONE_DEPLOY';
const VSTS_DEPLOY: string = 'VSTS';

export class KuduServiceUtility {
Expand Down Expand Up @@ -158,7 +159,7 @@ export class KuduServiceUtility {
}
}

public async deployUsingZipDeploy(packagePath: string, appOffline?: boolean, customMessage?: any): Promise<string> {
public async deployUsingZipDeploy(packagePath: string, appOffline?: boolean, customMessage?: any, addChecksumHeader?: boolean): Promise<string> {
try {
console.log(tl.loc('PackageDeploymentInitiated'));

Expand All @@ -176,7 +177,47 @@ export class KuduServiceUtility {
var deploymentMessage = this._getUpdateHistoryRequest(true, null, customMessage).message;
queryParameters.push('message=' + encodeURIComponent(deploymentMessage));

let deploymentDetails = await this._appServiceKuduService.zipDeploy(packagePath, queryParameters);
let deploymentDetails = await this._appServiceKuduService.zipDeploy(packagePath, queryParameters, addChecksumHeader);

await this._processDeploymentResponse(deploymentDetails);
if(appOffline) {
await this._appOfflineKuduService(physicalRootPath, false);
}

console.log(tl.loc('PackageDeploymentSuccess'));
return deploymentDetails.id;
}
catch(error) {
tl.error(tl.loc('PackageDeploymentFailed'));
throw Error(error);
}
}

public async deployUsingOneDeploy(packagePath: string, isClean: boolean, appOffline?: boolean, customMessage?: any, packageType?:string, addChecksumHeader?: boolean): Promise<string> {
try {
console.log(tl.loc('PackageDeploymentInitiatedWithOneDeploy'));

if(appOffline) {
await this._appOfflineKuduService(physicalRootPath, true);
tl.debug('Wait for 5 seconds for app_offline to take effect');
await webClient.sleepFor(5);
}

if (!packageType){
packageType = 'Zip'
}

let queryParameters: Array<string> = [
'async=true',
'deployer=' + VSTS_ONE_DEPLOY,
'type=' + packageType,
'clean=' + isClean
];

var deploymentMessage = this._getUpdateHistoryRequest(true, null, customMessage).message;
queryParameters.push('message=' + encodeURIComponent(deploymentMessage));

let deploymentDetails = await this._appServiceKuduService.oneDeploy(packagePath, queryParameters, addChecksumHeader);

await this._processDeploymentResponse(deploymentDetails);
if(appOffline) {
Expand All @@ -195,7 +236,7 @@ export class KuduServiceUtility {
public async deployUsingRunFromZip(packagePath: string, customMessage?: any) : Promise<void> {
try {
console.log(tl.loc('PackageDeploymentInitiated'));

let queryParameters: Array<string> = [
'deployer=' + VSTS_DEPLOY
];
Expand Down
18 changes: 18 additions & 0 deletions Tasks/AzureRmWebAppDeploymentV4/operations/TaskParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ export enum DeploymentType {
warDeploy
}

export enum DeploymentTypeLinux {
oneDeploy,
zipDeploy
}

type AdditionalArgumentsTelemetry = {
deploymentMethod: DeploymentType;
doubleQuoteCount: number;
Expand Down Expand Up @@ -109,6 +114,10 @@ export class TaskParametersUtility {
taskParameters.AdditionalArguments = tl.getInput('AdditionalArguments', false) || '';
}
}
else if(taskParameters.isLinuxApp) {
taskParameters.DeploymentTypeLinux = this.getDeploymentTypeLinux(tl.getInput('DeploymentTypeLinux', false));
taskParameters.CleanDeploymentFlag = tl.getBoolInput('CleanDeploymentFlag', false);
}
else {
// Retry Attempt is passed by default
taskParameters.AdditionalArguments = '-retryAttempts:6 -retryInterval:10000';
Expand Down Expand Up @@ -160,6 +169,13 @@ export class TaskParametersUtility {
}
}

private static getDeploymentTypeLinux(type): DeploymentTypeLinux {
switch(type) {
case "oneDeploy": return DeploymentTypeLinux.oneDeploy;
case "zipDeploy": return DeploymentTypeLinux.zipDeploy;
}
}

private static _getAdditionalArgumentsTelemetry(additionalArguments: string, deploymentType: DeploymentType): AdditionalArgumentsTelemetry {
const telemetry = {
deploymentMethod: deploymentType,
Expand Down Expand Up @@ -272,6 +288,8 @@ export interface TaskParameters {
XmlVariableSubstitution?: boolean;
UseWebDeploy?: boolean;
DeploymentType?: DeploymentType;
DeploymentTypeLinux?: DeploymentTypeLinux;
CleanDeploymentFlag?: boolean;
RemoveAdditionalFilesFlag?: boolean;
SetParametersFile?: string;
ExcludeFilesFromAppDataFlag?: boolean;
Expand Down
Loading