use of hudson.EnvVars in project support-core-plugin by jenkinsci.
the class AgentsConfigFileTest method agentsConfigFile.
@Test
public void agentsConfigFile() throws Exception {
j.createSlave("node1", "node1", new EnvVars());
AgentsConfigFile comp = new AgentsConfigFile();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
comp.addContents(new Container() {
@Override
public void add(@CheckForNull Content content) {
try {
content.writeTo(baos);
} catch (IOException e) {
fail(e.getMessage());
}
}
});
String fileContent = baos.toString();
assertTrue(fileContent.contains("<name>node1</name>"));
}
use of hudson.EnvVars in project sonar-scanner-jenkins by SonarSource.
the class TriggersConfigTest method build_parameters.
/**
* See SONARPLUGINS-1338
*/
@Test
public void build_parameters() throws IOException, InterruptedException {
AbstractBuild<?, ?> build = mockBuildWithCauses(new TriggersConfig.SonarCause());
EnvVars env_vars = new EnvVars();
when(build.getEnvironment(listener)).thenReturn(env_vars);
Map<String, String> build_vars = new HashMap<String, String>();
when(build.getBuildVariables()).thenReturn(build_vars);
assertThat(triggers.isSkipSonar(build, listener)).isNull();
triggers.setEnvVar("SKIP_SONAR");
assertThat(triggers.isSkipSonar(build, listener)).isNull();
build_vars.put("SKIP_SONAR", "true");
assertThat(triggers.isSkipSonar(build, listener)).isNotNull();
}
use of hudson.EnvVars in project sonar-scanner-jenkins by SonarSource.
the class TriggersConfigTest method env_var.
/**
* See SONARPLUGINS-1886
*/
@Test
public void env_var() throws IOException, InterruptedException {
AbstractBuild<?, ?> build = mockBuildWithCauses(new TriggersConfig.SonarCause());
EnvVars env_vars = new EnvVars();
when(build.getEnvironment(listener)).thenReturn(env_vars);
Map<String, String> build_vars = new HashMap<String, String>();
when(build.getBuildVariables()).thenReturn(build_vars);
assertThat(triggers.isSkipSonar(build, listener)).isNull();
triggers.setEnvVar("SKIP_SONAR");
assertThat(triggers.isSkipSonar(build, listener)).isNull();
env_vars.put("SKIP_SONAR", "true");
assertThat(triggers.isSkipSonar(build, listener)).isNotNull();
}
use of hudson.EnvVars in project evosuite by EvoSuite.
the class ProjectAction method perform.
public void perform(AbstractMavenProject<?, ?> project, AbstractBuild<?, ?> build, BuildListener listener) throws InterruptedException, IOException {
EnvVars env = build.getEnvironment(listener);
env.overrideAll(build.getBuildVariables());
VirtualChannel channel = build.getWorkspace().getChannel();
MavenModuleSet prj = (MavenModuleSet) this.project;
for (MavenModule module : prj.getModules()) {
FilePath fp = new FilePath(channel, build.getWorkspace().getRemote() + File.separator + (module.getRelativePath().isEmpty() ? "" : module.getRelativePath() + File.separator) + Properties.CTG_DIR + File.separator + Properties.CTG_PROJECT_INFO);
if (!fp.exists()) {
listener.getLogger().println(EvoSuiteRecorder.LOG_PREFIX + "There is not any " + fp.getRemote() + " file for module " + module.getName());
continue;
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
fp.copyTo(out);
ByteArrayInputStream projectXML = new ByteArrayInputStream(out.toByteArray());
listener.getLogger().println(EvoSuiteRecorder.LOG_PREFIX + "Analysing " + Properties.CTG_PROJECT_INFO + " file from " + fp.getRemote());
ModuleAction m = new ModuleAction(build, module.getName());
if (!m.build(channel, projectXML, listener)) {
continue;
}
this.modules.add(m);
}
}
use of hudson.EnvVars in project sonar-scanner-jenkins by SonarSource.
the class MsBuildSQRunnerBegin method perform.
@Override
public void perform(Run<?, ?> run, FilePath workspace, Launcher launcher, TaskListener listener) throws InterruptedException, IOException {
ArgumentListBuilder args = new ArgumentListBuilder();
EnvVars env = BuilderUtils.getEnvAndBuildVars(run, listener);
SonarInstallation sonarInstallation = getSonarInstallation(getSonarInstallationName(), listener);
MsBuildSQRunnerInstallation msBuildScanner = getDescriptor().getMsBuildScannerInstallation(msBuildScannerInstallationName);
run.addAction(new SonarQubeScannerMsBuildParams(msBuildScannerInstallationName, getSonarInstallationName()));
args.add(getExeName(msBuildScanner, env, launcher, listener, workspace));
Map<String, String> props = getSonarProps(sonarInstallation);
addArgsTo(args, sonarInstallation, env, props);
int result = launcher.launch().cmds(args).envs(env).stdout(listener).pwd(BuilderUtils.getModuleRoot(run, workspace)).join();
if (result != 0) {
throw new AbortException(Messages.MSBuildScanner_ExecFailed(result));
}
}
Aggregations