in nuget-agent/src/jetbrains/buildServer/nuget/agent/runner/credentials/NuGetCredentialsProvider.kt [39:86]
override fun beforeRunnerStart(runner: BuildRunnerContext) {
if (TeamCityProperties.getBoolean("teamcity.nuget.credentialprovider.disabled")) return
if (StringUtil.isTrue(runner.configParameters.get("teamcity.nuget.credentialprovider.disabled")?.trim())) return
val pathProvider = myCredentialsPathProviders[runner.runType]
if (pathProvider == null && !SupportedRunners.contains(runner.runType)) {
return
}
val packageSources = packageSourceManager.getGlobalPackageSources(runner.build)
if (packageSources.isEmpty()) return
if (LOG.isDebugEnabled) {
LOG.debug("Will provide credentials for NuGet package sources: " + packageSources.joinToString { it.source })
}
try {
FileUtil.createTempFile(runner.build.agentTempDirectory, "nuget-sources", ".xml", true)?.let {
mySourcesFile = it
PackageSourceUtil.writeSources(it, packageSources)
runner.addEnvironmentVariable(TEAMCITY_NUGET_FEEDS_ENV_VAR, it.path)
pathProvider?.getProviderPath(runner)?.let { credentialsProviderPath ->
LOG.debug("Set credentials provider location to $credentialsProviderPath")
runner.addEnvironmentVariable(NUGET_CREDENTIALPROVIDERS_PATH_ENV_VAR, credentialsProviderPath)
}
pathProvider?.getPluginPath(runner)?.let { pluginPaths ->
LOG.debug("Set credentials plugin paths to $pluginPaths")
runner.addEnvironmentVariable(NUGET_PLUGIN_PATH_ENV_VAR, pluginPaths)
}
val environmentVariables = runner.buildParameters.environmentVariables;
if (!environmentVariables.containsKey(NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS_ENV_VAR)) {
LOG.debug("Set NUGET handshake timeout to $NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS")
runner.addEnvironmentVariable(NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS_ENV_VAR, NUGET_PLUGIN_HANDSHAKE_TIMEOUT_IN_SECONDS.toString())
}
if (!environmentVariables.containsKey(NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS_ENV_VAR)) {
LOG.debug("Set NUGET request timeout to $NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS")
runner.addEnvironmentVariable(NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS_ENV_VAR, NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS.toString())
}
}
} catch (e: IOException) {
throw RunBuildException("Failed to create temp file for NuGet sources. " + e.message, e)
}
}