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

Support for project-scoped feeds in UniversalPackagesV0 #11342

Merged
merged 13 commits into from
Oct 22, 2019
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function registerArtifactToolUtilitiesMock(tmr: tmrm.TaskMockRunner, tool
getArtifactToolFromService: function(serviceUri, accessToken, toolName) {
return toolPath;
},
getPackageNameFromId: function(serviceUri: string, accessToken: string, feedId: string, packageId: string) {
getPackageNameFromId: function(serviceUri: string, accessToken: string, projectId: string, feedId: string, packageId: string) {
return packageId;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {IExecOptions, IExecSyncResult} from "azure-pipelines-task-lib/toolrunner

export interface IArtifactToolOptions {
artifactToolPath: string;
projectId: string;
feedId: string;
accountUrl: string;
packageName: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,21 @@ export function getVersionUtility(versionRadio: string, highestVersion: string):
}
}

export async function getPackageNameFromId(serviceUri: string, accessToken: string, feedId: string, packageId: string): Promise<string> {
export async function getPackageNameFromId(serviceUri: string, accessToken: string, projectId: string, feedId: string, packageId: string): Promise<string> {
const ApiVersion = "3.0-preview.1";
const PackagingAreaName = "Packaging";
const PackageAreaId = "7a20d846-c929-4acc-9ea2-0d5a7df1b197";

const feedConnection = pkgLocationUtils.getWebApiWithProxy(serviceUri, accessToken);

let routeValues = { feedId: feedId, packageId: packageId, project: projectId };
if (!projectId) {
delete routeValues.project;
}

// Getting url for feeds version API
const packageUrl = await new Promise<string>((resolve, reject) => {
let getVersioningDataPromise = feedConnection.vsoClient.getVersioningData(ApiVersion, PackagingAreaName, PackageAreaId, { feedId, packageId });
let getVersioningDataPromise = feedConnection.vsoClient.getVersioningData(ApiVersion, PackagingAreaName, PackageAreaId, routeValues);
getVersioningDataPromise.then((result) => {
return resolve(result.requestUrl);
});
Expand All @@ -138,16 +143,21 @@ export async function getPackageNameFromId(serviceUri: string, accessToken: stri
}
}

export async function getHighestPackageVersionFromFeed(serviceUri: string, accessToken: string, feedId: string, packageName: string): Promise<string> {
export async function getHighestPackageVersionFromFeed(serviceUri: string, accessToken: string, projectId: string, feedId: string, packageName: string): Promise<string> {
const ApiVersion = "3.0-preview.1";
const PackagingAreaName = "Packaging";
const PackageAreaId = "7a20d846-c929-4acc-9ea2-0d5a7df1b197";

const feedConnection = pkgLocationUtils.getWebApiWithProxy(serviceUri, accessToken);

let routeValues = { feedId: feedId, project: projectId };
if (!projectId) {
delete routeValues.project;
}

// Getting url for feeds version API
const packageUrl = await new Promise<string>((resolve, reject) => {
var getVersioningDataPromise = feedConnection.vsoClient.getVersioningData(ApiVersion, PackagingAreaName, PackageAreaId, { feedId }, {packageNameQuery: packageName, protocolType: "upack", includeDeleted: "true", includeUrls: "false"});
var getVersioningDataPromise = feedConnection.vsoClient.getVersioningData(ApiVersion, PackagingAreaName, PackageAreaId, routeValues, {packageNameQuery: packageName, protocolType: "upack", includeDeleted: "true", includeUrls: "false"});
getVersioningDataPromise.then((result) => {
return resolve(result.requestUrl);
});
Expand Down
2 changes: 1 addition & 1 deletion Tasks/DotNetCoreCLIV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"demands": [],
"version": {
"Major": 2,
"Minor": 158,
"Minor": 159,
"Patch": 0
},
"minimumAgentVersion": "2.115.0",
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 @@ -17,7 +17,7 @@
"demands": [],
"version": {
"Major": 2,
"Minor": 158,
"Minor": 159,
"Patch": 0
},
"minimumAgentVersion": "2.115.0",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/DownloadPackageV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"author": "ms-vscs-rm",
"version": {
"Major": 0,
"Minor": 158,
"Minor": 159,
"Patch": 0
},
"demands": [],
Expand Down
2 changes: 1 addition & 1 deletion Tasks/DownloadPackageV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"author": "ms-vscs-rm",
"version": {
"Major": 0,
"Minor": 158,
"Minor": 159,
"Patch": 0
},
"demands": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
"loc.messages.RedirectUrlError": "Unable to get redirect URL with error %.",
"loc.messages.UnsupportedArchiveType": "Unsupported archive type: %s",
"loc.messages.Error_UnexpectedErrorArtifactToolDownload": "An unexpected error occurred while trying to download the package. Exit code(%s) and error(%s)",
"loc.messages.Info_Downloading": "Downloading package: %s, version: %s using feed id: %s",
"loc.messages.Info_Downloading": "Downloading package: %s, version: %s using feed id: %s, project: %s",
"loc.messages.Info_UsingArtifactToolDownload": "Using artifact tool to download the package"
}
2 changes: 1 addition & 1 deletion Tasks/DownloadPackageV1/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function main(): Promise<void> {
var feed = getProjectAndFeedIdFromInputParam("feed");

if (packageType === "upack") {
return await downloadUniversalPackage(downloadPath, feed.feedId, packageId, version, filesPattern);
return await downloadUniversalPackage(downloadPath, feed.projectId, feed.feedId, packageId, version, filesPattern);
}

if (viewId && viewId.replace(/\s/g, "") !== "") {
Expand Down
4 changes: 2 additions & 2 deletions Tasks/DownloadPackageV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"author": "ms-vscs-rm",
"version": {
"Major": 1,
"Minor": 158,
"Minor": 159,
"Patch": 0
},
"demands": [],
Expand Down Expand Up @@ -182,7 +182,7 @@
"RedirectUrlError": "Unable to get redirect URL with error %.",
"UnsupportedArchiveType": "Unsupported archive type: %s",
"Error_UnexpectedErrorArtifactToolDownload": "An unexpected error occurred while trying to download the package. Exit code(%s) and error(%s)",
"Info_Downloading": "Downloading package: %s, version: %s using feed id: %s",
"Info_Downloading": "Downloading package: %s, version: %s using feed id: %s, project: %s",
salvmd marked this conversation as resolved.
Show resolved Hide resolved
"Info_UsingArtifactToolDownload": "Using artifact tool to download the package"
}
}
2 changes: 1 addition & 1 deletion Tasks/DownloadPackageV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"author": "ms-vscs-rm",
"version": {
"Major": 1,
"Minor": 158,
"Minor": 159,
"Patch": 0
},
"demands": [],
Expand Down
13 changes: 11 additions & 2 deletions Tasks/DownloadPackageV1/universal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as pkgLocationUtils from "packaging-common/locationUtilities";

export async function downloadUniversalPackage(
downloadPath: string,
projectId: string,
feedId: string,
packageId: string,
version: string,
Expand All @@ -28,6 +29,7 @@ export async function downloadUniversalPackage(
let packageName: string = await artifactToolUtilities.getPackageNameFromId(
feedUri,
accessToken,
projectId,
feedId,
packageId
);
Expand All @@ -36,6 +38,7 @@ export async function downloadUniversalPackage(

const downloadOptions = {
artifactToolPath,
projectId,
feedId,
accountUrl: serviceUri,
packageName,
Expand All @@ -52,6 +55,7 @@ export async function downloadUniversalPackage(
_logUniversalStartupVariables({
ArtifactToolPath: artifactToolPath,
PackageType: "Universal",
ProjectId: projectId,
FeedId : feedId,
PackageId: packageId,
Version: version,
Expand All @@ -69,7 +73,8 @@ function downloadPackageUsingArtifactTool(
let command = new Array<string>();
var verbosity = tl.getVariable("Packaging.ArtifactTool.Verbosity") || "Error";

command.push("universal", "download",
command.push(
"universal", "download",
"--feed", options.feedId,
"--service", options.accountUrl,
"--package-name", options.packageName,
Expand All @@ -79,7 +84,11 @@ function downloadPackageUsingArtifactTool(
"--verbosity", verbosity,
"--filter", filterPattern);

console.log(tl.loc("Info_Downloading", options.packageName, options.packageVersion, options.feedId));
if (options.projectId) {
command.push("--project", options.projectId);
}

console.log(tl.loc("Info_Downloading", options.packageName, options.packageVersion, options.feedId, options.projectId));
const execResult: IExecSyncResult = artifactToolRunner.runArtifactTool(
options.artifactToolPath,
command,
Expand Down
4 changes: 2 additions & 2 deletions Tasks/MavenV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 158,
"Patch": 1
"Minor": 159,
"Patch": 0
},
"releaseNotes": "Configuration of the SonarQube analysis was moved to the [SonarQube](https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarqube) or [SonarCloud](https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarcloud) extensions, in task `Prepare Analysis Configuration`",
"demands": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/MavenV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 158,
"Minor": 159,
"Patch": 0
},
"releaseNotes": "ms-resource:loc.releaseNotes",
Expand Down
4 changes: 2 additions & 2 deletions Tasks/MavenV3/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 3,
"Minor": 158,
"Patch": 1
"Minor": 159,
"Patch": 0
},
"releaseNotes": "Configuration of the SonarQube analysis was moved to the [SonarQube](https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarqube) or [SonarCloud](https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarcloud) extensions, in task `Prepare Analysis Configuration`",
"demands": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/MavenV3/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 3,
"Minor": 158,
"Minor": 159,
"Patch": 0
},
"releaseNotes": "ms-resource:loc.releaseNotes",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/NpmAuthenticateV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 158,
"Minor": 159,
"Patch": 0
},
"runsOn": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/NpmAuthenticateV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 158,
"Minor": 159,
"Patch": 0
},
"runsOn": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/NpmV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 158,
"Minor": 159,
"Patch": 0
},
"runsOn": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/NpmV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 158,
"Minor": 159,
"Patch": 0
},
"runsOn": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/NuGetCommandV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 158,
"Minor": 159,
"Patch": 0
},
"runsOn": [
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 @@ -9,7 +9,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 158,
"Minor": 159,
"Patch": 0
},
"runsOn": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/NuGetPublisherV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"author": "Lawrence Gripper",
"version": {
"Major": 0,
"Minor": 158,
"Minor": 159,
"Patch": 0
},
"runsOn": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/NuGetPublisherV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"author": "Lawrence Gripper",
"version": {
"Major": 0,
"Minor": 158,
"Minor": 159,
"Patch": 0
},
"runsOn": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/NuGetToolInstallerV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 158,
"Minor": 159,
"Patch": 0
},
"preview": false,
Expand Down
2 changes: 1 addition & 1 deletion Tasks/NuGetToolInstallerV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 158,
"Minor": 159,
"Patch": 0
},
"preview": false,
Expand Down
2 changes: 1 addition & 1 deletion Tasks/NuGetToolInstallerV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 158,
"Minor": 159,
"Patch": 0
},
"preview": false,
Expand Down
2 changes: 1 addition & 1 deletion Tasks/NuGetToolInstallerV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 158,
"Minor": 159,
"Patch": 0
},
"preview": false,
Expand Down
2 changes: 1 addition & 1 deletion Tasks/NuGetV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"helpMarkDown": "",
"version": {
"Major": 0,
"Minor": 158,
"Minor": 159,
"Patch": 0
},
"runsOn": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/NuGetV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"helpMarkDown": "ms-resource:loc.helpMarkDown",
"version": {
"Major": 0,
"Minor": 158,
"Minor": 159,
"Patch": 0
},
"runsOn": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/PipAuthenticateV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"category": "Package",
"version": {
"Major": 0,
"Minor": 158,
"Minor": 159,
"Patch": 0
},
"runsOn": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/PipAuthenticateV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"category": "Package",
"version": {
"Major": 0,
"Minor": 158,
"Minor": 159,
"Patch": 0
},
"runsOn": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/TwineAuthenticateV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"category": "Package",
"version": {
"Major": 0,
"Minor": 158,
"Minor": 159,
"Patch": 0
},
"runsOn": [
Expand Down
Loading