// Just to make sure they differ from projectA's build numbers.
projectB.updateNextBuildNumber(3);
int expectedBuildNumber = projectB.getNextBuildNumber();
projectA.scheduleBuild2(0, new UserCause()).get();
Run buildB1 = projectB.getBuildByNumber(expectedBuildNumber);
EnvVars envVars = builder.getEnvVars();
//System.out.println("envVars: " + envVars);
assertThat(envVars, notNullValue());
assertThat(envVars, hasEntry("LAST_TRIGGERED_JOB_NAME", "projectB"));
assertThat(envVars, hasEntry("TRIGGERED_BUILD_NUMBER_projectB", Integer.toString(expectedBuildNumber)));
assertThat(envVars, hasEntry("TRIGGERED_BUILD_RESULT_projectB", buildB1.getResult().toString()));
assertThat(envVars, hasEntry("TRIGGERED_BUILD_RESULT_projectB_RUN_" + Integer.toString(expectedBuildNumber), buildB1.getResult().toString()));
assertThat(envVars, hasEntry("TRIGGERED_BUILD_RUN_COUNT_projectB", "1"));
assertThat(envVars, hasEntry("TRIGGERED_JOB_NAMES", "projectB"));
// The below test for expectedBuildNumber is meaningless if the
// value doesn't update, though it should always update.
assertThat(projectB.getNextBuildNumber(), is(not(expectedBuildNumber)));
expectedBuildNumber = projectB.getNextBuildNumber();
AbstractBuild<?, ?> buildA2 = projectA.scheduleBuild2(0, new UserCause()).get();
envVars = builder.getEnvVars();
assertThat(envVars, notNullValue());
assertThat(envVars, hasEntry("LAST_TRIGGERED_JOB_NAME", "projectB"));
assertThat(envVars, hasEntry("TRIGGERED_BUILD_NUMBER_projectB", Integer.toString(expectedBuildNumber)));