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

Hotfix/upack existing package #14489

Merged
merged 8 commits into from
May 26, 2021
Merged
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
2 changes: 1 addition & 1 deletion Tasks/UniversalPackagesV0/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "universalpackages",
"version": "0.0.7",
"version": "0.0.8",
"description": "Download or publish universal packages.",
"main": "universalmain.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion Tasks/UniversalPackagesV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"category": "Package",
"version": {
"Major": 0,
"Minor": 182,
"Minor": 188,
"Patch": 0
},
"runsOn": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/UniversalPackagesV0/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": 182,
"Minor": 188,
"Patch": 0
},
"runsOn": [
Expand Down
25 changes: 16 additions & 9 deletions Tasks/UniversalPackagesV0/universalpublish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export async function run(artifactToolPath: string): Promise<void> {
let version: string;
let accessToken: string;
let feedUri: string;
let publishStatus: number;
let execResult: IExecSyncResult;
const publishedPackageVar: string = tl.getInput("publishedPackageVar");
const versionRadio = tl.getInput("versionPublishSelector");

Expand Down Expand Up @@ -111,13 +111,13 @@ export async function run(artifactToolPath: string): Promise<void> {
packageVersion: version,
} as artifactToolRunner.IArtifactToolOptions;

publishStatus = publishPackageUsingArtifactTool(publishDir, publishOptions, toolRunnerOptions);
execResult = publishPackageUsingArtifactTool(publishDir, publishOptions, toolRunnerOptions);

var retries = 0;
let newVersion: string;

//If package already exist, retry with a newer version, do not retry for custom version
while (retries < numRetries && publishStatus != null && publishStatus === packageAlreadyExistsError && versionRadio !== "custom") {
while (retries < numRetries && execResult != null && execResult.code === packageAlreadyExistsError && versionRadio !== "custom") {
[serviceUri, packageName, feedId, projectId, accessToken] = authSetup(feedType);
if (feedType == "internal") {
internalAuthInfo = new auth.InternalAuthInfo([], accessToken);
Expand All @@ -144,12 +144,19 @@ export async function run(artifactToolPath: string): Promise<void> {
packageVersion: newVersion,
} as artifactToolRunner.IArtifactToolOptions;
tl.debug(tl.loc("Info_PublishingRetry", publishOptions.packageName, version, newVersion));
publishStatus = publishPackageUsingArtifactTool(publishDir, publishOptions, toolRunnerOptions);
execResult = publishPackageUsingArtifactTool(publishDir, publishOptions, toolRunnerOptions);
version = newVersion;
retries++;
}

if(publishedPackageVar) {
if (execResult.code === packageAlreadyExistsError) {
telemetry.logResult("Packaging", "UniversalPackagesCommand", execResult.code);
throw new Error(tl.loc("Error_UnexpectedErrorArtifactTool",
execResult.code,
execResult.stderr ? execResult.stderr.trim() : execResult.stderr));
}

if (publishedPackageVar) {
tl.setVariable(publishedPackageVar, `${packageName} ${version}`);
}

Expand Down Expand Up @@ -197,7 +204,7 @@ function publishPackageUsingArtifactTool(

//Retry if package exist error occurs
if (execResult.code == packageAlreadyExistsError) {
return execResult.code;
return execResult;
}

telemetry.logResult("Packaging", "UniversalPackagesCommand", execResult.code);
Expand All @@ -219,10 +226,10 @@ async function getNextPackageVersion(
projectId,
feedId,
packageName);

if(highestVersion != null) {
version= artifactToolUtilities.getVersionUtility(tl.getInput("versionPublishSelector"), highestVersion);
}
version= artifactToolUtilities.getVersionUtility(tl.getInput("versionPublishSelector"), highestVersion);
}

if(version == null) {
throw new Error(tl.loc("FailedToGetLatestPackageVersion"));
Expand Down