Skip to content

Commit 37d0f6d

Browse files
author
Peter Spillman
authored
Users/pspill/upack savepublishmetadata default (#9561) (#9563)
* Dot not read Packaging.SavePublishMetadata to opt-in to creating provenance session * bump upack minor version
1 parent 2555eb3 commit 37d0f6d

File tree

3 files changed

+40
-34
lines changed

3 files changed

+40
-34
lines changed

Tasks/UniversalPackagesV0/task.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"category": "Package",
99
"version": {
1010
"Major": 0,
11-
"Minor": 145,
12-
"Patch": 2
11+
"Minor": 146,
12+
"Patch": 0
1313
},
1414
"runsOn": [
1515
"Agent",

Tasks/UniversalPackagesV0/task.loc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"category": "Package",
99
"version": {
1010
"Major": 0,
11-
"Minor": 145,
12-
"Patch": 2
11+
"Minor": 146,
12+
"Patch": 0
1313
},
1414
"runsOn": [
1515
"Agent",

Tasks/UniversalPackagesV0/universalpublish.ts

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import * as artifactToolUtilities from "./Common/ArtifactToolUtilities";
88
import * as auth from "./Common/Authentication";
99

1010
export async function run(artifactToolPath: string): Promise<void> {
11-
let buildIdentityDisplayName: string = null;
12-
let buildIdentityAccount: string = null;
11+
const buildIdentityDisplayName: string = null;
12+
const buildIdentityAccount: string = null;
1313
try {
1414
// Get directory to publish
15-
let publishDir: string = tl.getInput("publishDirectory");
15+
const publishDir: string = tl.getInput("publishDirectory");
1616
if (publishDir.length < 1)
1717
{
1818
tl.debug(tl.loc("Info_PublishDirectoryNotFound"));
@@ -25,7 +25,7 @@ export async function run(artifactToolPath: string): Promise<void> {
2525
let version: string;
2626
let accessToken: string;
2727
let feedUri: string;
28-
let publishedPackageVar: string = tl.getInput("publishedPackageVar");
28+
const publishedPackageVar: string = tl.getInput("publishedPackageVar");
2929
const versionRadio = tl.getInput("versionPublishSelector");
3030

3131
// Feed Auth
@@ -40,7 +40,7 @@ export async function run(artifactToolPath: string): Promise<void> {
4040

4141
let internalAuthInfo: auth.InternalAuthInfo;
4242

43-
let toolRunnerOptions = artifactToolRunner.getOptions();
43+
const toolRunnerOptions = artifactToolRunner.getOptions();
4444

4545
let sessionId: string;
4646

@@ -58,28 +58,24 @@ export async function run(artifactToolPath: string): Promise<void> {
5858

5959
toolRunnerOptions.env.UNIVERSAL_PUBLISH_PAT = internalAuthInfo.accessToken;
6060

61-
// creating session
62-
const useSessionEnabled = tl.getVariable("Packaging.SavePublishMetadata");
63-
if (useSessionEnabled) {
64-
let packagingLocation: string;
65-
try {
66-
// This call is to get the packaging URI(abc.pkgs.vs.com) which is same for all protocols.
67-
packagingLocation = await pkgLocationUtils.getNuGetUriFromBaseServiceUri(
68-
serviceUri,
69-
accessToken);
70-
} catch (error) {
71-
tl.debug(JSON.stringify(error));
72-
packagingLocation = serviceUri;
73-
}
74-
75-
const pkgConn = pkgLocationUtils.getWebApiWithProxy(packagingLocation, accessToken);
76-
sessionId = await ProvenanceHelper.GetSessionId(
77-
feedId,
78-
"upack", /* must match protocol name on the server */
79-
pkgConn.serverUrl,
80-
[pkgConn.authHandler],
81-
pkgConn.options);
61+
let packagingLocation: string;
62+
try {
63+
// This call is to get the packaging URI(abc.pkgs.vs.com) which is same for all protocols.
64+
packagingLocation = await pkgLocationUtils.getNuGetUriFromBaseServiceUri(
65+
serviceUri,
66+
accessToken);
67+
} catch (error) {
68+
tl.debug(JSON.stringify(error));
69+
packagingLocation = serviceUri;
8270
}
71+
72+
const pkgConn = pkgLocationUtils.getWebApiWithProxy(packagingLocation, accessToken);
73+
sessionId = await ProvenanceHelper.GetSessionId(
74+
feedId,
75+
"upack", /* must match protocol name on the server */
76+
pkgConn.serverUrl,
77+
[pkgConn.authHandler],
78+
pkgConn.options);
8379
}
8480
else {
8581
const externalAuthInfo = auth.GetExternalAuthInfo("externalEndpoints");
@@ -105,7 +101,11 @@ export async function run(artifactToolPath: string): Promise<void> {
105101
else{
106102
feedUri = await pkgLocationUtils.getFeedUriFromBaseServiceUri(serviceUri, accessToken);
107103

108-
let highestVersion = await artifactToolUtilities.getHighestPackageVersionFromFeed(feedUri, accessToken, feedId, packageName);
104+
const highestVersion = await artifactToolUtilities.getHighestPackageVersionFromFeed(
105+
feedUri,
106+
accessToken,
107+
feedId,
108+
packageName);
109109

110110
version = artifactToolUtilities.getVersionUtility(tl.getInput("versionPublishSelector"), highestVersion);
111111
}
@@ -141,8 +141,11 @@ export async function run(artifactToolPath: string): Promise<void> {
141141
}
142142
}
143143

144-
function publishPackageUsingArtifactTool(publishDir: string, options: artifactToolRunner.IArtifactToolOptions, execOptions: IExecOptions) {
145-
let command = new Array<string>();
144+
function publishPackageUsingArtifactTool(
145+
publishDir: string,
146+
options: artifactToolRunner.IArtifactToolOptions,
147+
execOptions: IExecOptions) {
148+
const command = new Array<string>();
146149
command.push("universal", "publish",
147150
"--feed", options.feedId,
148151
"--service", options.accountUrl,
@@ -154,7 +157,10 @@ function publishPackageUsingArtifactTool(publishDir: string, options: artifactTo
154157
"--description", tl.getInput("packagePublishDescription"));
155158

156159
console.log(tl.loc("Info_Publishing", options.packageName, options.packageVersion, options.feedId));
157-
const execResult: IExecSyncResult = artifactToolRunner.runArtifactTool(options.artifactToolPath, command, execOptions);
160+
const execResult: IExecSyncResult = artifactToolRunner.runArtifactTool(
161+
options.artifactToolPath,
162+
command,
163+
execOptions);
158164

159165
if (execResult.code === 0) {
160166
return;

0 commit comments

Comments
 (0)