in rake-runner-agent/src/jetbrains/buildServer/agent/ruby/rvm/RVMCommandLineProcessor.java [35:125]
public ProgramCommandLine process(@NotNull final BuildRunnerContext context, @NotNull final ProgramCommandLine origCommandLine)
throws RunBuildException {
if (!SystemInfo.isUnix) {
return origCommandLine;
}
final AgentRunningBuild build = context.getBuild();
// check if feature is enabled
final Collection<AgentBuildFeature> features =
build.getBuildFeaturesOfType(RubyEnvConfiguratorConstants.RUBY_ENV_CONFIGURATOR_FEATURE_TYPE);
if (features.isEmpty()) {
return origCommandLine;
}
final Map<String, String> featureParameters = features.iterator().next().getParameters();
final RubyEnvConfiguratorConfiguration configuration = new RubyEnvConfiguratorConfiguration(featureParameters);
// Remove some env variables
final Map<String, String> environment = new HashMap<String, String>(origCommandLine.getEnvironment());
String envsToUnsetStr = context.getRunnerParameters().get(RubyEnvConfiguratorService.ENVS_TO_UNSET_PARAM);
if (envsToUnsetStr != null) {
List<String> envs = StringUtil.split(envsToUnsetStr, ",");
for (String key : envs) {
environment.remove(key);
}
}
switch (configuration.getType()) {
case INTERPRETER_PATH: {
return new ProgramCommandLine() {
@NotNull
public String getExecutablePath() throws RunBuildException {
return origCommandLine.getExecutablePath();
}
@NotNull
public String getWorkingDirectory() throws RunBuildException {
return origCommandLine.getWorkingDirectory();
}
public String getCommandLineForLogging(PasswordReplacer passwordReplacer) throws RunBuildException {
return origCommandLine.getCommandLineForLogging(passwordReplacer);
}
@NotNull
public List<String> getArguments() throws RunBuildException {
return origCommandLine.getArguments();
}
@NotNull
public Map<String, String> getEnvironment() {
return environment;
}
};
}
case RBENV:
case RBENV_FILE:
case RVM:
case RVM_RUBY_VERSION:
case RVMRC: {
// Lets patch it!
final File script = createScriptFile(origCommandLine, build.getAgentTempDirectory());
return new ProgramCommandLine() {
@NotNull
public String getExecutablePath() {
return CUSTOM_EXECUTABLE;
}
@NotNull
public String getWorkingDirectory() throws RunBuildException {
return origCommandLine.getWorkingDirectory();
}
@NotNull
public List<String> getArguments() {
return Collections.singletonList(script.getAbsolutePath());
}
@NotNull
public Map<String, String> getEnvironment() {
return environment;
}
};
}
default:
throw new RunBuildException("Unsupported REC configuration type " + configuration.getType());
}
}