Skip to content

Commit

Permalink
Merge branch 'master' into users/shmittal/Core01
Browse files Browse the repository at this point in the history
  • Loading branch information
20shivangi authored Sep 17, 2019
2 parents 0c85576 + 3ec956d commit 65d83d9
Show file tree
Hide file tree
Showing 18 changed files with 77 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
"loc.messages.Error_NoSourceSpecifiedForPush": "No source was specified for push",
"loc.messages.Error_NoValueFoundForEnvVar": "No value was found for the provided environment variable.",
"loc.messages.Error_NoVersionFoundInBuildNumber": "Could not find version number data in the following environment variable: BUILD_BUILDNUMBER. The value of the variable should contain a substring with the following formats: X.Y.Z or X.Y.Z.A where A, X, Y, and Z are positive integers.",
"loc.messages.Error_PackageFailure": "An error ocurred while trying to pack the files.",
"loc.messages.Error_PackageFailure": "An error occurred while trying to pack the files.",
"loc.messages.Error_PushNotARegularFile": "%s is not a file. Check the 'Path/Pattern to nupkg' property of the task.",
"loc.messages.Info_AttemptingToPackFile": "Attempting to pack file: ",
"loc.messages.Info_NoPackagesMatchedTheSearchPattern": "No packages matched the search pattern.",
Expand Down
4 changes: 2 additions & 2 deletions Tasks/DotNetCoreCLIV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 2,
"Minor": 158,
"Patch": 0
"Patch": 1
},
"minimumAgentVersion": "2.115.0",
"instanceNameFormat": "dotnet $(command)",
Expand Down Expand Up @@ -514,7 +514,7 @@
"Error_NoSourceSpecifiedForPush": "No source was specified for push",
"Error_NoValueFoundForEnvVar": "No value was found for the provided environment variable.",
"Error_NoVersionFoundInBuildNumber": "Could not find version number data in the following environment variable: BUILD_BUILDNUMBER. The value of the variable should contain a substring with the following formats: X.Y.Z or X.Y.Z.A where A, X, Y, and Z are positive integers.",
"Error_PackageFailure": "An error ocurred while trying to pack the files.",
"Error_PackageFailure": "An error occurred while trying to pack the files.",
"Error_PushNotARegularFile": "%s is not a file. Check the 'Path/Pattern to nupkg' property of the task.",
"Info_AttemptingToPackFile": "Attempting to pack file: ",
"Info_NoPackagesMatchedTheSearchPattern": "No packages matched the search pattern.",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/DotNetCoreCLIV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 2,
"Minor": 158,
"Patch": 0
"Patch": 1
},
"minimumAgentVersion": "2.115.0",
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"loc.friendlyName": "Deploy Kubernetes manifests",
"loc.friendlyName": "Deploy to Kubernetes",
"loc.helpMarkDown": "[Learn more about this task](https://go.microsoft.com/fwlink/?linkid=851275) or [see the Kubernetes documentation](https://kubernetes.io/docs/home/)",
"loc.description": "Use Kubernetes manifest files to deploy to clusters or even bake the manifest files to be used for deployments using Helm charts",
"loc.instanceNameFormat": "$(action)",
Expand Down
4 changes: 2 additions & 2 deletions Tasks/KubernetesManifestV0/task.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "DEE316A2-586F-4DEF-BE79-488A1F503DFE",
"name": "KubernetesManifest",
"friendlyName": "Deploy Kubernetes manifests",
"friendlyName": "Deploy to Kubernetes",
"description": "Use Kubernetes manifest files to deploy to clusters or even bake the manifest files to be used for deployments using Helm charts",
"helpUrl": "https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/kubernetes-manifest",
"helpMarkDown": "[Learn more about this task](https://go.microsoft.com/fwlink/?linkid=851275) or [see the Kubernetes documentation](https://kubernetes.io/docs/home/)",
Expand All @@ -14,7 +14,7 @@
"version": {
"Major": 0,
"Minor": 158,
"Patch": 0
"Patch": 1
},
"demands": [],
"groups": [],
Expand Down
2 changes: 1 addition & 1 deletion Tasks/KubernetesManifestV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 0,
"Minor": 158,
"Patch": 0
"Patch": 1
},
"demands": [],
"groups": [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"loc.friendlyName": "Deploy to Kubernetes",
"loc.friendlyName": "Kubectl",
"loc.helpMarkDown": "[Learn more about this task](https://go.microsoft.com/fwlink/?linkid=851275)",
"loc.description": "Deploy, configure, update a Kubernetes cluster in Azure Container Service by running kubectl commands",
"loc.instanceNameFormat": "kubectl $(command)",
Expand Down
4 changes: 2 additions & 2 deletions Tasks/KubernetesV0/task.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "CBC316A2-586F-4DEF-BE79-488A1F503564",
"name": "Kubernetes",
"friendlyName": "Deploy to Kubernetes",
"friendlyName": "Kubectl",
"description": "Deploy, configure, update a Kubernetes cluster in Azure Container Service by running kubectl commands",
"helpUrl": "https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/kubernetes",
"helpMarkDown": "[Learn more about this task](https://go.microsoft.com/fwlink/?linkid=851275)",
Expand All @@ -13,7 +13,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 157,
"Minor": 158,
"Patch": 0
},
"demands": [],
Expand Down
4 changes: 2 additions & 2 deletions Tasks/KubernetesV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 157,
"Minor": 158,
"Patch": 0
},
"demands": [],
Expand Down Expand Up @@ -370,4 +370,4 @@
"OutputVariableDataSizeExceeded": "ms-resource:loc.messages.OutputVariableDataSizeExceeded",
"WritingDockerConfigToTempFile": "ms-resource:loc.messages.WritingDockerConfigToTempFile"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"loc.friendlyName": "Deploy to Kubernetes",
"loc.friendlyName": "Kubectl",
"loc.helpMarkDown": "[Learn more about this task](https://go.microsoft.com/fwlink/?linkid=851275) or [see the Kubernetes documentation](https://kubernetes.io/docs/home/)",
"loc.description": "Deploy, configure, update a Kubernetes cluster in Azure Container Service by running kubectl commands",
"loc.instanceNameFormat": "kubectl $(command)",
Expand Down
4 changes: 2 additions & 2 deletions Tasks/KubernetesV1/task.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "CBC316A2-586F-4DEF-BE79-488A1F503564",
"name": "Kubernetes",
"friendlyName": "Deploy to Kubernetes",
"friendlyName": "Kubectl",
"description": "Deploy, configure, update a Kubernetes cluster in Azure Container Service by running kubectl commands",
"helpUrl": "https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/kubernetes",
"helpMarkDown": "[Learn more about this task](https://go.microsoft.com/fwlink/?linkid=851275) or [see the Kubernetes documentation](https://kubernetes.io/docs/home/)",
Expand All @@ -14,7 +14,7 @@
"version": {
"Major": 1,
"Minor": 158,
"Patch": 1
"Patch": 2
},
"demands": [],
"releaseNotes": "What's new in Version 1.0:<br/>&nbsp;Added new service connection type input for easy selection of Azure AKS cluster.<br/>&nbsp;Replaced output variable input with output variables section that we had added in all tasks.",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/KubernetesV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 1,
"Minor": 158,
"Patch": 1
"Patch": 2
},
"demands": [],
"releaseNotes": "ms-resource:loc.releaseNotes",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"loc.messages.Error_NoVersionFoundInBuildNumber": "Could not find version number data in the following environment variable: BUILD_BUILDNUMBER. The value of the variable should contain a substring with the following formats: X.Y.Z or X.Y.Z.A where A, X, Y, and Z are positive integers.",
"loc.messages.Warning_MoreThanOneVersionInBuildNumber": "Found more than one instance of version data in BUILD_BUILDNUMBER.Assuming first instance is version.",
"loc.messages.Error_NoValueFoundForEnvVar": "No value was found for the provided environment variable.",
"loc.messages.Error_PackageFailure": "An error ocurred while trying to pack the files.",
"loc.messages.Error_PackageFailure": "An error occurred while trying to pack the files.",
"loc.messages.Info_AttemptingToPackFile": "Attempting to pack file: ",
"loc.messages.Warning_NoConfigForOldNuGet": "To connect to NuGet feeds hosted in your Azure DevOps organization with NuGet 3.1 or below, edit your build pipeline to specify a path to a NuGet.config containing the package sources you wish to use.",
"loc.messages.PackagesPublishedSuccessfully": "Packages were published successfully",
Expand Down
4 changes: 2 additions & 2 deletions Tasks/NuGetCommandV2/nugetpublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ function publishPackageNuGet(
if (execResult.code !== 0) {
telemetry.logResult("Packaging", "NuGetCommand", execResult.code);
if(continueOnConflict && execResult.stderr.indexOf("The feed already contains")>0){
tl.debug(`A conflict ocurred with package ${packageFile}, ignoring it since "Allow duplicates" was selected.`);
tl.debug(`A conflict occurred with package ${packageFile}, ignoring it since "Allow duplicates" was selected.`);
return {
code: 0,
stdout: execResult.stderr,
Expand Down Expand Up @@ -336,7 +336,7 @@ function publishPackageVstsNuGetPush(packageFile: string, options: IVstsNuGetPus

// ExitCode 2 means a push conflict occurred
if (execResult.code === 2 && options.settings.continueOnConflict) {
tl.debug(`A conflict ocurred with package ${packageFile}, ignoring it since "Allow duplicates" was selected.`);
tl.debug(`A conflict occurred with package ${packageFile}, ignoring it since "Allow duplicates" was selected.`);
return;
}

Expand Down
4 changes: 2 additions & 2 deletions Tasks/NuGetCommandV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"version": {
"Major": 2,
"Minor": 158,
"Patch": 0
"Patch": 1
},
"runsOn": [
"Agent",
Expand Down Expand Up @@ -491,7 +491,7 @@
"Error_NoVersionFoundInBuildNumber": "Could not find version number data in the following environment variable: BUILD_BUILDNUMBER. The value of the variable should contain a substring with the following formats: X.Y.Z or X.Y.Z.A where A, X, Y, and Z are positive integers.",
"Warning_MoreThanOneVersionInBuildNumber": "Found more than one instance of version data in BUILD_BUILDNUMBER.Assuming first instance is version.",
"Error_NoValueFoundForEnvVar": "No value was found for the provided environment variable.",
"Error_PackageFailure": "An error ocurred while trying to pack the files.",
"Error_PackageFailure": "An error occurred while trying to pack the files.",
"Info_AttemptingToPackFile": "Attempting to pack file: ",
"Warning_NoConfigForOldNuGet": "To connect to NuGet feeds hosted in your Azure DevOps organization with NuGet 3.1 or below, edit your build pipeline to specify a path to a NuGet.config containing the package sources you wish to use.",
"PackagesPublishedSuccessfully": "Packages were published successfully",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/NuGetCommandV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"version": {
"Major": 2,
"Minor": 158,
"Patch": 0
"Patch": 1
},
"runsOn": [
"Agent",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,28 @@ mockery.registerMock('azure-pipelines-task-lib/task', {

import { DotNetCoreVersionFetcher } from "../versionfetcher";
import { VersionInfo } from '../models';
let versionFetcher = new DotNetCoreVersionFetcher();
try {
let versionInfo = new VersionInfo(JSON.parse(`{"version":"2.2.104", "files": [{"name": "linux.tar.gz", "rid":"linux-x64", "url": "https://path.to/file.tar.gz"}, {"name": "osx.pkg", "rid":"osx-x64", "url": "https://path.to/file.pkg"}, {"name": "osx.tar.gz", "rid":"osx-x64", "url": "https://path.toMac/file.tar.gz"}, {"name": "win.exe", "rid":"win-x64", "url": "https://path.to/file.exe"}, {"name": "win.zip", "rid":"win-x64", "url": "https://path.to/file.zip"}]}`), "sdk");

// Test for windows
osType = "win";
let versionFetcher = new DotNetCoreVersionFetcher();
let downloadUrl = versionFetcher.getDownloadUrl(versionInfo);
if (downloadUrl != "https://path.to/file.zip") {
throw "";
}

// Test for linux
osType = "linux";
versionFetcher = new DotNetCoreVersionFetcher();
downloadUrl = versionFetcher.getDownloadUrl(versionInfo);
if (downloadUrl != "https://path.to/file.tar.gz") {
throw "";
}

// Test for mac os
osType = "osx";
versionFetcher = new DotNetCoreVersionFetcher();
downloadUrl = versionFetcher.getDownloadUrl(versionInfo);
if (downloadUrl != "https://path.toMac/file.tar.gz") {
throw "";
Expand Down
100 changes: 51 additions & 49 deletions Tasks/UseDotNetV2/versionfetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import * as utils from "./versionutilities";

export class DotNetCoreVersionFetcher {
private explicitVersioning: boolean = false;
private channels: Channel[];
private httpCallbackClient: httpClient.HttpClient;
private machineOsSuffixes: string[];
constructor(explicitVersioning: boolean = false) {
this.explicitVersioning = explicitVersioning;
let proxyUrl: string = tl.getVariable("agent.proxyurl");
Expand Down Expand Up @@ -58,9 +61,9 @@ export class DotNetCoreVersionFetcher {
public getDownloadUrl(versionInfo: VersionInfo): string {
console.log(tl.loc("GettingDownloadUrl", versionInfo.getPackageType(), versionInfo.getVersion()));

let osSuffixes = this.detectMachineOS();
this.detectMachineOS();
let downloadPackageInfoObject: VersionFilesData = null;
osSuffixes.find((osSuffix) => {
this.machineOsSuffixes.find((osSuffix) => {
downloadPackageInfoObject = versionInfo.getFiles().find((downloadPackageInfo: VersionFilesData) => {
if (downloadPackageInfo.rid && osSuffix && downloadPackageInfo.rid.toLowerCase() == osSuffix.toLowerCase()) {
if ((osSuffix.split("-")[0] == "win" && downloadPackageInfo.name.endsWith(".zip")) || (osSuffix.split("-")[0] != "win" && downloadPackageInfo.name.endsWith("tar.gz"))) {
Expand All @@ -79,7 +82,7 @@ export class DotNetCoreVersionFetcher {
return downloadPackageInfoObject.url;
}

throw tl.loc("DownloadUrlForMatchingOsNotFound", versionInfo.getPackageType(), versionInfo.getVersion(), osSuffixes.toString());
throw tl.loc("DownloadUrlForMatchingOsNotFound", versionInfo.getPackageType(), versionInfo.getVersion(), this.machineOsSuffixes.toString());
}

private setReleasesIndex(): Promise<void> {
Expand Down Expand Up @@ -162,7 +165,7 @@ export class DotNetCoreVersionFetcher {
tl.debug(tl.loc("VersionInformationNotComplete", release[packageType].version, err));
}
}
if (release && release[packageType] && release[packageType].version && !versionInfoList.find((versionInfo) => { return versionInfo.getVersion() === release[packageType].version }) ) {
if (release && release[packageType] && release[packageType].version && !versionInfoList.find((versionInfo) => { return versionInfo.getVersion() === release[packageType].version })) {
try {
let versionInfo: VersionInfo = new VersionInfo(release[packageType], packageType);
versionInfoList.push(versionInfo);
Expand Down Expand Up @@ -223,58 +226,60 @@ export class DotNetCoreVersionFetcher {
return adjacentChannels;
}

private detectMachineOS(): string[] {
let osSuffix = [];
let scriptRunner: trm.ToolRunner;
private detectMachineOS(): void {
if (!this.machineOsSuffixes) {
let osSuffix = [];
let scriptRunner: trm.ToolRunner;

try {
console.log(tl.loc("DetectingPlatform"));
if (tl.osType().match(/^Win/)) {
let escapedScript = path.join(this.getCurrentDir(), 'externals', 'get-os-platform.ps1').replace(/'/g, "''");
let command = `& '${escapedScript}'`;

let powershellPath = tl.which('powershell', true);
scriptRunner = tl.tool(powershellPath)
.line('-NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command')
.arg(command);
}
else {
let scriptPath = path.join(this.getCurrentDir(), 'externals', 'get-os-distro.sh');
this.setFileAttribute(scriptPath, "777");

try {
console.log(tl.loc("DetectingPlatform"));
if (tl.osType().match(/^Win/)) {
let escapedScript = path.join(this.getCurrentDir(), 'externals', 'get-os-platform.ps1').replace(/'/g, "''");
let command = `& '${escapedScript}'`
scriptRunner = tl.tool(tl.which(scriptPath, true));
}

let powershellPath = tl.which('powershell', true);
scriptRunner = tl.tool(powershellPath)
.line('-NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command')
.arg(command);
}
else {
let scriptPath = path.join(this.getCurrentDir(), 'externals', 'get-os-distro.sh');
this.setFileAttribute(scriptPath, "777");
let result: trm.IExecSyncResult = scriptRunner.execSync();

scriptRunner = tl.tool(tl.which(scriptPath, true));
}
if (result.code != 0) {
throw tl.loc("getMachinePlatformFailed", result.error ? result.error.message : result.stderr);
}

let result: trm.IExecSyncResult = scriptRunner.execSync();
let output: string = result.stdout;

if (result.code != 0) {
throw tl.loc("getMachinePlatformFailed", result.error ? result.error.message : result.stderr);
}
let index;
if ((index = output.indexOf("Primary:")) >= 0) {
let primary = output.substr(index + "Primary:".length).split(os.EOL)[0];
osSuffix.push(primary);
console.log(tl.loc("PrimaryPlatform", primary));
}

let output: string = result.stdout;
if ((index = output.indexOf("Legacy:")) >= 0) {
let legacy = output.substr(index + "Legacy:".length).split(os.EOL)[0];
osSuffix.push(legacy);
console.log(tl.loc("LegacyPlatform", legacy));
}

let index;
if ((index = output.indexOf("Primary:")) >= 0) {
let primary = output.substr(index + "Primary:".length).split(os.EOL)[0];
osSuffix.push(primary);
console.log(tl.loc("PrimaryPlatform", primary));
if (osSuffix.length == 0) {
throw tl.loc("CouldNotDetectPlatform");
}
}

if ((index = output.indexOf("Legacy:")) >= 0) {
let legacy = output.substr(index + "Legacy:".length).split(os.EOL)[0];
osSuffix.push(legacy);
console.log(tl.loc("LegacyPlatform", legacy));
catch (ex) {
throw tl.loc("FailedInDetectingMachineArch", JSON.stringify(ex));
}

if (osSuffix.length == 0) {
throw tl.loc("CouldNotDetectPlatform");
}
}
catch (ex) {
throw tl.loc("FailedInDetectingMachineArch", JSON.stringify(ex));
this.machineOsSuffixes = osSuffix;
}

return osSuffix;
}

private setFileAttribute(file: string, mode: string): void {
Expand All @@ -284,9 +289,6 @@ export class DotNetCoreVersionFetcher {
private getCurrentDir(): string {
return __dirname;
}

private channels: Channel[];
private httpCallbackClient: httpClient.HttpClient;
}

const DotNetCoreReleasesIndexUrl: string = "https://raw.githubusercontent.com/dotnet/core/master/release-notes/releases-index.json";
const DotNetCoreReleasesIndexUrl: string = "https://raw.githubusercontent.com/dotnet/core/master/release-notes/releases-index.json";

0 comments on commit 65d83d9

Please sign in to comment.