in runAs-agent/src/main/java/jetbrains/buildServer/runAs/agent/UserCredentialsServiceImpl.java [33:98]
public UserCredentials tryGetUserCredentials() {
final boolean allowCustomCredentials = ParameterUtils.parseBoolean(myParametersService.tryGetConfigParameter(Constants.ALLOW_CUSTOM_CREDENTIALS), true);
final boolean allowProfileIdFromServer = ParameterUtils.parseBoolean(myParametersService.tryGetConfigParameter(Constants.ALLOW_PROFILE_ID_FROM_SERVER), false);
if(allowCustomCredentials && allowProfileIdFromServer) {
String profileRef = myParametersService.tryGetParameter(Constants.CREDENTIALS_PROFILE_ID);
final boolean profileWasDefined = !StringUtil.isEmptyOrSpaces(profileRef);
UserCredentials profileCredentials = null;
if(!profileWasDefined) {
profileCredentials = getPredefinedProfile(DEFAULT_PROFILE, false);
if(LOG.isDebugEnabled()) {
LOG.debug("tryGetUserCredentials predefined \"" + Constants.CREDENTIALS_PROFILE_ID + "\": " + profileCredentials);
}
}
UserCredentials customCredentials = tryGetCustomCredentials();
if(customCredentials != null) {
if(profileWasDefined || profileCredentials != null) {
LOG.info("Build step attempted to use custom credentials while credentials profiles are configured on the agent. Build step has not been executed and build problem was raised.");
throw new BuildStartException("Build step cannot be executed with custom credentials on this agent. Please contact system administrator.");
}
if(LOG.isDebugEnabled()) {
LOG.debug("tryGetUserCredentials custom: " + customCredentials);
}
return customCredentials;
}
if (!profileWasDefined) {
return profileCredentials;
}
profileCredentials = getPredefinedProfile(profileRef, true);
if(LOG.isDebugEnabled()) {
LOG.debug("tryGetUserCredentials predefined \"" + profileRef + "\": " + profileCredentials);
}
return profileCredentials;
}
if(allowCustomCredentials) {
UserCredentials customCredentials = tryGetCustomCredentials();
if(LOG.isDebugEnabled()) {
LOG.debug("tryGetUserCredentials custom: " + customCredentials);
}
return customCredentials;
}
if(allowProfileIdFromServer) {
String credentialsRef = myParametersService.tryGetConfigParameter(Constants.CREDENTIALS_PROFILE_ID);
if (StringUtil.isEmptyOrSpaces(credentialsRef)) {
credentialsRef = DEFAULT_PROFILE;
}
UserCredentials profileCredentials = getPredefinedProfile(credentialsRef, true);
if(LOG.isDebugEnabled()) {
LOG.debug("tryGetUserCredentials predefined \"" + credentialsRef + "\": " + profileCredentials);
}
return profileCredentials;
}
LOG.debug("tryGetUserCredentials returns null");
return null;
}