azure-pipelines-tasks-artifacts-common
Advanced tools
Comparing version 2.244.2 to 2.244.3
@@ -157,24 +157,32 @@ "use strict"; | ||
const existingCredentialsArray = configuredEndpoints ? JSON.parse(configuredEndpoints)['endpointCredentials'] : []; | ||
if (serviceConnections && serviceConnections.length) { | ||
console.log(tl.loc('CredProvider_SettingUpForServiceConnections')); | ||
// Ideally we'd also show the service connection name, but the agent doesn't expose it :-( | ||
serviceConnections.map(authInfo => `${authInfo.packageSource.uri}`).forEach(serviceConnectionUri => console.log(' ' + serviceConnectionUri)); | ||
console.log(); | ||
var credentialContainer; | ||
if (existingCredentialsArray.length > 0) { | ||
// Verify that any new service connections are not already in the existing credentials | ||
for (const serviceConnection of serviceConnections) { | ||
const matchedCredential = existingCredentialsArray.find(cred => cred['endpoint'] === serviceConnection.packageSource.uri); | ||
if (matchedCredential) { | ||
throw Error(tl.loc('CredProvider_Error_ServiceConnectionExists', matchedCredential['endpoint'])); | ||
} | ||
var mergedCredentials = existingCredentialsArray.concat(JSON.parse(buildExternalFeedEndpointsJson(serviceConnections))['endpointCredentials']); | ||
credentialContainer = JSON.stringify({ 'endpointCredentials': mergedCredentials }); | ||
var credentialContainer; | ||
// no-op if no service connections are provided | ||
if (!serviceConnections || serviceConnections.length === 0) { | ||
return; | ||
} | ||
console.log(tl.loc('CredProvider_SettingUpForServiceConnections')); | ||
// Ideally we'd also show the service connection name, but the agent doesn't expose it :-( | ||
serviceConnections.map(authInfo => `${authInfo.packageSource.uri}`).forEach(serviceConnectionUri => console.log(' ' + serviceConnectionUri)); | ||
console.log(); | ||
if (existingCredentialsArray.length > 0) { | ||
var newCredentials = []; | ||
for (const serviceConnection of serviceConnections) { | ||
// If endpoint is a repeat or has already been added, warn and skip | ||
if (existingCredentialsArray.find(cred => cred['endpoint'] == serviceConnection.packageSource.uri) || | ||
newCredentials.find(cred => cred.packageSource.uri == serviceConnection.packageSource.uri)) { | ||
tl.warning(tl.loc('CredProvider_Error_ServiceConnectionExists', serviceConnection.packageSource.uri)); | ||
continue; | ||
} | ||
newCredentials.push(serviceConnection); | ||
} | ||
else { | ||
credentialContainer = buildExternalFeedEndpointsJson(serviceConnections); | ||
if (newCredentials.length === 0) { | ||
return; | ||
} | ||
tl.setVariable(CRED_PROVIDER_EXTERNAL_ENDPOINTS_ENVVAR, credentialContainer, false /* while this contains secrets, we need the environment variable to be set */); | ||
var mergedCredentials = existingCredentialsArray.concat(JSON.parse(buildExternalFeedEndpointsJson(newCredentials))['endpointCredentials']); | ||
credentialContainer = JSON.stringify({ 'endpointCredentials': mergedCredentials }); | ||
} | ||
else { | ||
credentialContainer = buildExternalFeedEndpointsJson(serviceConnections); | ||
} | ||
tl.setVariable(CRED_PROVIDER_EXTERNAL_ENDPOINTS_ENVVAR, credentialContainer, false /* while this contains secrets, we need the environment variable to be set */); | ||
} | ||
@@ -181,0 +189,0 @@ exports.configureCredProviderForServiceConnectionFeeds = configureCredProviderForServiceConnectionFeeds; |
@@ -13,3 +13,3 @@ { | ||
"CredProvider_InstallingNetFxTo": "Installing the Azure Artifacts Credential Provider (.NET Framework) to '%s'. This credential provider is compatible with nuget.exe 4.8.0.5385 or later, and MSBuild 15.8.166.59604 or later.", | ||
"CredProvider_Error_ServiceConnectionExists": "An existing service connection already exists for the endpoint '%s'.", | ||
"CredProvider_Error_ServiceConnectionExists": "An existing service connection already exists for the endpoint '%s'. Skipping authentication for current configuration.", | ||
"CredProvider_SettingUpForOrgFeeds": "Setting up the credential provider to use the identity '%s' for feeds in your organization/collection starting with:", | ||
@@ -16,0 +16,0 @@ "CredProvider_SettingUpForServiceConnections": "Setting up the credential provider for these service connections:", |
{ | ||
"name": "azure-pipelines-tasks-artifacts-common", | ||
"version": "2.244.2", | ||
"version": "2.244.3", | ||
"description": "Azure Artifacts common code (for new authentication tasks)", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
113362
1581