Skip to content

Commit

Permalink
Merge branch 'master' into users/vithati/k8sm
Browse files Browse the repository at this point in the history
  • Loading branch information
vithati authored Oct 22, 2019
2 parents c9c7d42 + 8feb5ad commit 9c0a66b
Show file tree
Hide file tree
Showing 52 changed files with 668 additions and 52 deletions.
2 changes: 1 addition & 1 deletion Tasks/AzureAppServiceManageV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"version": {
"Major": 0,
"Minor": 2,
"Patch": 61
"Patch": 62
},
"minimumAgentVersion": "1.102.0",
"instanceNameFormat": "$(Action): $(WebAppName)",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureAppServiceManageV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"version": {
"Major": 0,
"Minor": 2,
"Patch": 61
"Patch": 62
},
"minimumAgentVersion": "1.102.0",
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 2,
"Minor": 154,
"Patch": 10
"Patch": 11
},
"demands": [
"azureps"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 2,
"Minor": 154,
"Patch": 10
"Patch": 11
},
"demands": [
"azureps"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV3/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 3,
"Minor": 154,
"Patch": 10
"Patch": 11
},
"preview": true,
"demands": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV3/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 3,
"Minor": 154,
"Patch": 10
"Patch": 11
},
"preview": true,
"demands": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureKeyVaultV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 1,
"Minor": 155,
"Patch": 4
"Patch": 5
},
"demands": [],
"minimumAgentVersion": "2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureKeyVaultV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 1,
"Minor": 155,
"Patch": 4
"Patch": 5
},
"demands": [],
"minimumAgentVersion": "2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureMonitorAlertsV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 0,
"Minor": 159,
"Patch": 0
"Patch": 1
},
"minimumAgentVersion": "2.111.0",
"instanceNameFormat": "Configure Azure Alerts : $(ResourceName)",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureMonitorAlertsV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 0,
"Minor": 159,
"Patch": 0
"Patch": 1
},
"minimumAgentVersion": "2.111.0",
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureMysqlDeploymentV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"version": {
"Major": 1,
"Minor": 156,
"Patch": 11
"Patch": 12
},
"demands": [],
"minimumAgentVersion": "1.100.0",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureMysqlDeploymentV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"version": {
"Major": 1,
"Minor": 156,
"Patch": 11
"Patch": 12
},
"demands": [],
"minimumAgentVersion": "1.100.0",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzurePowerShellV4/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"version": {
"Major": 4,
"Minor": 159,
"Patch": 2
"Patch": 3
},
"releaseNotes": "Added support for Az Module and cross platform agents.",
"groups": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzurePowerShellV4/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"version": {
"Major": 4,
"Minor": 159,
"Patch": 2
"Patch": 3
},
"releaseNotes": "ms-resource:loc.releaseNotes",
"groups": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureResourceGroupDeploymentV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 2,
"Minor": 157,
"Patch": 4
"Patch": 5
},
"demands": [],
"minimumAgentVersion": "2.119.1",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureResourceGroupDeploymentV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 2,
"Minor": 157,
"Patch": 4
"Patch": 5
},
"demands": [],
"minimumAgentVersion": "2.119.1",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureResourceManagerTemplateDeploymentV3/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 3,
"Minor": 1,
"Patch": 0
"Patch": 1
},
"preview": "true",
"demands": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 3,
"Minor": 1,
"Patch": 0
"Patch": 1
},
"preview": "true",
"demands": [],
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureRmWebAppDeploymentV4/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 4,
"Minor": 157,
"Patch": 5
"Patch": 6
},
"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.",
"minimumAgentVersion": "2.104.1",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureRmWebAppDeploymentV4/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 4,
"Minor": 157,
"Patch": 5
"Patch": 6
},
"releaseNotes": "ms-resource:loc.releaseNotes",
"minimumAgentVersion": "2.104.1",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureVmssDeploymentV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 0,
"Minor": 1,
"Patch": 3
"Patch": 4
},
"demands": [],
"minimumAgentVersion": "2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureVmssDeploymentV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 0,
"Minor": 1,
"Patch": 3
"Patch": 4
},
"demands": [],
"minimumAgentVersion": "2.0.0",
Expand Down
46 changes: 30 additions & 16 deletions Tasks/Common/azure-arm-rest-v2/AzureServiceClientBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,32 +140,46 @@ export class AzureServiceClientBase {
timeoutInMinutes = timeoutInMinutes || this.longRunningOperationRetryTimeout;
var timeout = new Date().getTime() + timeoutInMinutes * 60 * 1000;
var waitIndefinitely = timeoutInMinutes == 0;
var ignoreTimeoutErrorThreshold = 5;
var request = new webClient.WebRequest();
request.method = "GET";
request.uri = response.headers["azure-asyncoperation"] || response.headers["location"];
if (!request.uri) {
throw new Error(tl.loc("InvalidResponseLongRunningOperation"));
}
while (true) {
response = await this.beginRequest(request);
tl.debug(`Response status code : ${response.statusCode}`);
if (response.statusCode === 202 || (response.body && (response.body.status == "Accepted" || response.body.status == "Running" || response.body.status == "InProgress"))) {
if(response.body && response.body.status) {
tl.debug(`Response status : ${response.body.status}`);
try {
response = await this.beginRequest(request);
tl.debug(`Response status code : ${response.statusCode}`);
if (response.statusCode === 202 || (response.body && (response.body.status == "Accepted" || response.body.status == "Running" || response.body.status == "InProgress"))) {
if (response.body && response.body.status) {
tl.debug(`Response status : ${response.body.status}`);
}
// If timeout; throw;
if (!waitIndefinitely && timeout < new Date().getTime()) {
throw new Error(tl.loc("TimeoutWhileWaiting"));
}

// Retry after given interval.
var sleepDuration = 15;
if (response.headers["retry-after"]) {
sleepDuration = parseInt(response.headers["retry-after"]);
}
await this.sleepFor(sleepDuration);
} else {
break;
}
// If timeout; throw;
if (!waitIndefinitely && timeout < new Date().getTime()) {
throw new Error(tl.loc("TimeoutWhileWaiting"));
}
catch (error) {
let errorString: string = (!!error && error.toString()) || "";
if(!!errorString && errorString.toLowerCase().indexOf("request timeout") >= 0 && ignoreTimeoutErrorThreshold > 0) {
// Ignore Request Timeout error and continue polling operation
tl.debug(`Request Timeout: ${request.uri}`);
ignoreTimeoutErrorThreshold--;
}

// Retry after given interval.
var sleepDuration = 15;
if (response.headers["retry-after"]) {
sleepDuration = parseInt(response.headers["retry-after"]);
else {
throw error;
}
await this.sleepFor(sleepDuration);
} else {
break;
}
}

Expand Down
78 changes: 78 additions & 0 deletions Tasks/Common/func-tools-common/functoolsutility.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
"use strict";

import * as fs from 'fs';
import * as os from 'os';
import * as util from 'util';
import * as tl from "azure-pipelines-task-lib/task";
import * as toolLib from 'azure-pipelines-tool-lib/tool';
import * as path from "path";

const funcToolName = 'func';
const stableFuncToolsVersion = '2.7.1585';

function getExecutableExtension(): string {
if (os.type().match(/^Win/)) {
return '.exe';
}

return '';
}

function getDownloadUrl(version: string) {
let downloadUrlFormat = 'https://github.com/Azure/azure-functions-core-tools/releases/download/%s/Azure.Functions.Cli.%s.%s.zip';
switch (os.type()) {
case 'Linux':
return util.format(downloadUrlFormat, version, 'linux-x64', version);

case 'Darwin':
return util.format(downloadUrlFormat, version, 'osx-x64', version);

case 'Windows_NT':
default:
return util.format(downloadUrlFormat, version, 'win-x86', version);

}
}

export async function getLatestFuncToolsVersion(): Promise<string> {
const funcToolsLatestReleaseUrl = 'https://api.github.com/repos/Azure/azure-functions-core-tools/releases/latest';
let latestVersion = stableFuncToolsVersion;

try {
const downloadPath = await toolLib.downloadTool(funcToolsLatestReleaseUrl);
const response = JSON.parse(fs.readFileSync(downloadPath, 'utf8').toString().trim());
if (response.tag_name) {
latestVersion = response.tag_name;
}
} catch (error) {
tl.warning(tl.loc('ErrorFetchingLatestVersion', funcToolsLatestReleaseUrl, error, stableFuncToolsVersion));
}

return latestVersion;
}

export async function downloadFuncTools(version: string): Promise<string> {
let cachedToolpath = toolLib.findLocalTool(funcToolName, version);

if (!cachedToolpath) {
const downloadUrl = getDownloadUrl(version);
let downloadPath;
try {
downloadPath = await toolLib.downloadTool(downloadUrl);
}
catch (ex) {
throw new Error(tl.loc('FuncDownloadFailed', downloadUrl, ex));
}

tl.debug('Extracting the downloaded func tool zip..');
const unzippedFuncPath = await toolLib.extractZip(downloadPath);
cachedToolpath = await toolLib.cacheDir(unzippedFuncPath, funcToolName, version);
console.log(tl.loc("SuccessfullyDownloaded", version, cachedToolpath));
} else {
console.log(tl.loc("VersionAlreadyInstalled", version, cachedToolpath));
}

const funcPath = path.join(cachedToolpath, funcToolName + getExecutableExtension());
fs.chmodSync(funcPath, '777');
return funcPath;
}
Loading

0 comments on commit 9c0a66b

Please sign in to comment.