本文整理汇总了Java中hudson.matrix.MatrixRun类的典型用法代码示例。如果您正苦于以下问题:Java MatrixRun类的具体用法?Java MatrixRun怎么用?Java MatrixRun使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MatrixRun类属于hudson.matrix包,在下文中一共展示了MatrixRun类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testMatrixToMatrix
import hudson.matrix.MatrixRun; //导入依赖的package包/类
/** Test artifact copy between matrix jobs, for artifact from matching axis */
@Test
public void testMatrixToMatrix() throws Exception {
MatrixProject other = createMatrixArtifactProject(),
p = createMatrixProject();
p.setAxes(new AxisList(new Axis("FOO", "one", "two"))); // should match other job
p.getBuildersList().add(CopyArtifactUtil.createRunSelector(other.getName() + "/FOO=$FOO", null,
new StatusRunSelector(StatusRunSelector.BuildStatus.STABLE), "", "", false, false, true));
rule.assertBuildStatusSuccess(other.scheduleBuild2(0, new UserCause()).get());
MatrixBuild b = p.scheduleBuild2(0, new UserCause()).get();
rule.assertBuildStatusSuccess(b);
MatrixRun r = b.getRun(new Combination(Collections.singletonMap("FOO", "one")));
assertFile(true, "one.txt", r);
assertFile(false, "two.txt", r);
r = b.getRun(new Combination(Collections.singletonMap("FOO", "two")));
assertFile(false, "one.txt", r);
assertFile(true, "two.txt", r);
}
示例2: getPollingLogFile
import hudson.matrix.MatrixRun; //导入依赖的package包/类
@Nonnull
public File getPollingLogFile() {
File pollingFile;
if (nonNull(job)) {
pollingFile = job.getRootDir();
} else if (run instanceof MatrixRun) {
MatrixRun matrixRun = (MatrixRun) run;
pollingFile = matrixRun.getParentBuild().getRootDir();
} else if (run instanceof MatrixBuild) {
pollingFile = run.getRootDir();
} else if (nonNull(run)) {
pollingFile = run.getRootDir();
} else {
throw new IllegalStateException("Can't get polling log file: no run or job initialised");
}
return new File(pollingFile, getPollingFileName());
}
示例3: matrixProjectTest
import hudson.matrix.MatrixRun; //导入依赖的package包/类
@Test
public void matrixProjectTest() throws IOException, InterruptedException, ExecutionException {
EnvVars env;
MatrixProject p = jenkins.jenkins.createProject(MatrixProject.class, "matrixbuild");
GitLabWebHookCause cause = new GitLabWebHookCause(generateCauseData());
// set up 2x2 matrix
AxisList axes = new AxisList();
axes.add(new TextAxis("db","mysql","oracle"));
axes.add(new TextAxis("direction","north","south"));
p.setAxes(axes);
MatrixBuild build = p.scheduleBuild2(0, cause).get();
List<MatrixRun> runs = build.getRuns();
assertEquals(4,runs.size());
for (MatrixRun run : runs) {
env = run.getEnvironment(listener);
assertNotNull(env.get("db"));
assertEnv(env);
}
}
示例4: ghCauseFromRun
import hudson.matrix.MatrixRun; //导入依赖的package包/类
/**
* matrix-project requires special extraction.
*/
@CheckForNull
public static <T extends Cause> T ghCauseFromRun(Run<?, ?> run, Class<T> tClass) {
if (run instanceof MatrixRun) {
MatrixBuild parentBuild = ((MatrixRun) run).getParentBuild();
if (nonNull(parentBuild)) {
return parentBuild.getCause(tClass);
}
} else {
return run.getCause(tClass);
}
return null;
}
示例5: testChildStatuses
import hudson.matrix.MatrixRun; //导入依赖的package包/类
@Test
public void testChildStatuses() throws Exception {
final MatrixProject matrixProject = jRule.jenkins.createProject(MatrixProject.class, "matrix-project");
matrixProject.addProperty(getPreconfiguredProperty(ghRule.getGhRepo()));
matrixProject.addTrigger(getPreconfiguredPRTrigger());
matrixProject.getBuildersList().add(new GitHubPRStatusBuilder());
matrixProject.getBuildersList().add(new Shell("sleep 10"));
matrixProject.getPublishersList().add(new GitHubPRBuildStatusPublisher());
matrixProject.getPublishersList().add(new GitHubPRCommentPublisher(new GitHubPRMessage("Comment"), null, null));
matrixProject.setAxes(
new AxisList(
new TextAxis("first_axis", "first_value1", "first_value2"),
new TextAxis("second_axis", "sec_value1", "sec_value2")
)
);
matrixProject.save();
super.basicTest(matrixProject);
for (MatrixBuild build : matrixProject.getBuilds()) {
for (MatrixRun matrixRun : build.getRuns()) {
jRule.assertLogNotContains("\tat", matrixRun);
}
}
}
示例6: buildEnvironmentFor
import hudson.matrix.MatrixRun; //导入依赖的package包/类
@Override
public void buildEnvironmentFor(@Nonnull Run r, @Nonnull EnvVars envs, @Nonnull TaskListener listener) throws IOException, InterruptedException {
GitLabWebHookCause cause = null;
if (r instanceof MatrixRun) {
MatrixBuild parent = ((MatrixRun)r).getParentBuild();
if (parent != null) {
cause = (GitLabWebHookCause) parent.getCause(GitLabWebHookCause.class);
}
} else {
cause = (GitLabWebHookCause) r.getCause(GitLabWebHookCause.class);
}
if (cause != null) {
envs.overrideAll(cause.getData().getBuildVariables());
}
}
示例7: abortRunning
import hudson.matrix.MatrixRun; //导入依赖的package包/类
public synchronized int abortRunning(int number) throws IllegalAccessException {
int aborted = 0;
Computer[] computers = getJenkinsInstance().getComputers();
for (Computer computer : computers) {
if (isNull(computer)) {
continue;
}
List<Executor> executors = computer.getExecutors();
executors.addAll(computer.getOneOffExecutors());
for (Executor executor : executors) {
if (isNull(executor) || !executor.isBusy() || nonNull(executor.getCauseOfDeath()) ||
!getInterruptCauses(executor).isEmpty() || getInterruptStatus(executor) == Result.ABORTED) {
continue;
}
Queue.Executable executable = executor.getCurrentExecutable();
final SubTask parent = executable.getParent();
if (!(executable instanceof Run)) {
continue;
}
final Run executableRun = (Run) executable;
if (!(parent instanceof Job)) {
continue;
}
final Job parentJob = (Job) parent;
if (!parentJob.getFullName().equals(job.getFullName())) {
// name doesn't match
continue;
}
if (executableRun.getResult() == Result.ABORTED) {
// was already aborted
continue;
}
if (executableRun instanceof MatrixRun) {
// the whole MatrixBuild will be aborted
continue;
}
// if (executable instanceof MatrixBuild) {
// final MatrixBuild executable1 = (MatrixBuild) executable;
// executable1.doStop()
// }
final GitHubPRCause causeAction = (GitHubPRCause) executableRun.getCause(GitHubPRCause.class);
if (nonNull(causeAction) && causeAction.getNumber() == number) {
LOGGER.info("Aborting '{}', by interrupting '{}'", executableRun, executor);
executor.interrupt(Result.ABORTED, new NewPRInterruptCause());
aborted++;
}
}
}
return aborted;
}
示例8: testAbortRunningMatrixProject
import hudson.matrix.MatrixRun; //导入依赖的package包/类
@Test
@RandomlyFails(value = "No idea why matrix doesn't work normally")
public void testAbortRunningMatrixProject() throws Exception {
MockFolder folder = j.createFolder("Matrix_folder");
MatrixProject job1 = folder.createProject(MatrixProject.class, "project1");
job1.setDisplayName("project1 display name");
job1.setConcurrentBuild(true);
job1.getBuildersList().add(new SleepBuilder());
job1.setAxes(
new AxisList(
new TextAxis("first_axis", "first_value1"),
new TextAxis("second_axis", "sec_value1")
)
);
configRoundTripUnsecure(job1);
job1.save();
MatrixProject job2 = folder.createProject(MatrixProject.class, "project2");
job2.setDisplayName("project1 display name");
job2.setConcurrentBuild(true);
job2.getBuildersList().add(new SleepBuilder());
job2.setAxes(
new AxisList(
new TextAxis("first_axis", "first_value1"),
new TextAxis("second_axis", "sec_value1")
)
);
configRoundTripUnsecure(job2);
job2.save();
MatrixProject job3 = folder.createProject(MatrixProject.class, "project3");
job3.setDisplayName("project1 display name");
job3.setConcurrentBuild(true);
job3.getBuildersList().add(new SleepBuilder());
job3.setAxes(
new AxisList(
new TextAxis("first_axis", "first_value1"),
new TextAxis("second_axis", "sec_value1")
)
);
configRoundTripUnsecure(job3);
job3.save();
testAbortRunning(job1, job2, job3);
assertThat(job1.getBuilds(), hasSize(3));
for (MatrixBuild matrixBuild : job1.getBuilds()) {
assertThat(matrixBuild.getResult(), is(Result.ABORTED));
assertThat(matrixBuild.getRuns(), not(empty()));
for (MatrixRun matrixRun : matrixBuild.getRuns()) {
assertThat(matrixRun.getResult(), is(Result.ABORTED));
}
}
}
示例9: onCompleted
import hudson.matrix.MatrixRun; //导入依赖的package包/类
@Override
public void onCompleted(Run run, TaskListener listener) {
if (run instanceof MatrixRun) {
return;
}
try {
EnvVars env = run.getEnvironment(listener);
String fail = env.get(ReviewProp.FAIL.getProp());
String pass = env.get(ReviewProp.PASS.getProp());
Result result = run.getResult();
if (result == null) {
logger.warning("Result is null!");
return;
}
Jenkins j = Jenkins.getInstance();
if (j == null) {
logger.warning("Jenkins instance is null!");
return;
}
// only process valid URLs (this gets triggered for non Reviews too)
String url = (result.equals(Result.SUCCESS)) ? pass : fail;
if (url != null && !url.isEmpty()) {
String rootUrl = j.getRootUrl();
if (rootUrl == null) {
JenkinsLocationConfiguration globalConfig = new JenkinsLocationConfiguration();
rootUrl = (globalConfig.getUrl() == null) ? "unset" : globalConfig.getUrl();
}
String path = run.getUrl();
postURL(url, rootUrl + path);
}
} catch (Exception e) {
logger.warning("Unable to Notify Review");
e.printStackTrace();
}
return;
}
示例10: hasResult
import hudson.matrix.MatrixRun; //导入依赖的package包/类
@Override
protected boolean hasResult(final MatrixRun run) {
return getAction(run) != null;
}
示例11: getResult
import hudson.matrix.MatrixRun; //导入依赖的package包/类
@Override
protected DependencyCheckResult getResult(final MatrixRun run) {
return getAction(run).getResult();
}
示例12: getAction
import hudson.matrix.MatrixRun; //导入依赖的package包/类
private DependencyCheckResultAction getAction(final MatrixRun run) {
return run.getAction(DependencyCheckResultAction.class);
}
示例13: getResult
import hudson.matrix.MatrixRun; //导入依赖的package包/类
@Override
protected CheckStyleResult getResult(final MatrixRun run) {
return getAction(run).getResult();
}
示例14: getAction
import hudson.matrix.MatrixRun; //导入依赖的package包/类
private CheckStyleResultAction getAction(final MatrixRun run) {
return run.getAction(CheckStyleResultAction.class);
}