Java 类hudson.model.Build 实例源码

项目:starwars-plugin    文件:StarWarsRecorderTest.java   
public void testGetProjectActionHavingLastBuildGivesStarWarsAction() {
    AbstractProject mockProject = mock(AbstractProject.class);
    Build mockBuild = mock(Build.class);
    Quote expectedQuote = generateQuote(StarWarsResult.SUCCESS);

    when(mockProject.getLastBuild()).thenReturn(mockBuild);
    when(mockBuild.getResult()).thenReturn(Result.SUCCESS);

    when(mockQuotesGenerator.generate(StarWarsResult.SUCCESS)).thenReturn(expectedQuote);

    Action action = recorder.getProjectAction(mockProject);

    assertTrue(action instanceof StarWarsAction);
    assertEquals(StarWarsResult.SUCCESS, ((StarWarsAction) action).getResult());
    assertNotNull(((StarWarsAction) action).getQuote());
}
项目:dockerhub-notification-plugin    文件:DockerPullImageBuilder.java   
@Nonnull
@Override
public Collection<String> getDockerImagesUsedByJob(@Nonnull Job<?,?> job) {
    if (job instanceof Project) {
        Project<? extends Project, ? extends Build> project = (Project<?,? extends Build>)job;
        Set<String> images = new HashSet<String>();
        // check DockerHub build step for matching image ID
        for (Builder b : project.getBuilders()) {
            if (b instanceof DockerPullImageBuilder) {
                images.add(((DockerPullImageBuilder)b).getImage());
            }
        }
        return images;
    } else {
        return Collections.emptySet();
    }
}
项目:DotCi    文件:DynamicBuild.java   
@Override
public Object getDynamic(final String token, final StaplerRequest req, final StaplerResponse rsp) {
    try {
        final Build item = getRun(Combination.fromString(token));
        if (item != null) {
            if (item.getNumber() == this.getNumber()) {
                return item;
            } else {
                // redirect the user to the correct URL
                String url = Functions.joinPath(item.getUrl(), req.getRestOfPath());
                final String qs = req.getQueryString();
                if (qs != null) {
                    url += '?' + qs;
                }
                throw HttpResponses.redirectViaContextPath(url);
            }
        }
    } catch (final IllegalArgumentException e) {
        // failed to parse the token as Combination. Must be something else
    }
    return super.getDynamic(token, req, rsp);
}
项目:openshift-deployer-plugin    文件:TestUtils.java   
protected static void assertBuildLogContains(String msg, Build<?,?> build, String str) throws IOException {
    assertNotNull("Build shouldn't be null", build);
    assertNotNull("Pattern shouldn't be null", str);

    String log = FileUtils.readFileToString(build.getLogFile());
    System.out.println(log);
    assertNotNull("Build log shouldn't be null", log);
    assertTrue(msg, log.contains(str));
}
项目:DotCi    文件:DynamicBuild.java   
public Build getRun(final Combination combination) {
    for (final DynamicSubProject subProject : getAllSubProjects()) {
        if (subProject.getCombination().equals(combination)) {
            return getRunForConfiguration(subProject);
        }

    }
    return null;
}
项目:DotCi    文件:DynamicRunPtr.java   
public String getNearestRunUrl() {
    final
    Build r = getRun();
    if (r == null) {
        return null;
    }
    if (this.dynamicBuild.getNumber() == r.getNumber()) {
        return getShortUrl() + "/console";
    }
    return Stapler.getCurrentRequest().getContextPath() + '/' + r.getUrl();
}
项目:DotCi    文件:DynamicRunPtr.java   
public String getTooltip() {
    final Build r = getRun();
    if (r != null) {
        return r.getIconColor().getDescription();
    }
    final Queue.Item item = Jenkins.getInstance().getQueue().getItem(this.dynamicBuild.getParent().getItem(this.combination));
    if (item != null) {
        return item.getWhy();
    }
    return null; // fall back
}
项目:jenkins.py    文件:BuilderPW.java   
@Override
public boolean perform(Build<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
    initPython();
    if (pexec.isImplemented(7)) {
        return pexec.execPythonBool("perform", build, launcher, listener);
    } else {
        return super.perform(build, launcher, listener);
    }
}
项目:jenkins.py    文件:RecorderPW.java   
@Override
public boolean perform(Build<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
    initPython();
    if (pexec.isImplemented(7)) {
        return pexec.execPythonBool("perform", build, launcher, listener);
    } else {
        return super.perform(build, launcher, listener);
    }
}
项目:jenkins.py    文件:NotifierPW.java   
@Override
public boolean perform(Build<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
    initPython();
    if (pexec.isImplemented(7)) {
        return pexec.execPythonBool("perform", build, launcher, listener);
    } else {
        return super.perform(build, launcher, listener);
    }
}
项目:openshift-deployer-plugin    文件:TestUtils.java   
protected static void assertDeploySucceeded(Build<?,?> build) throws IOException {
    assertBuildLogContains("Deploy wasn't successful.", build, "Application deployed to http://");
}
项目:DotCi    文件:DynamicRunPtr.java   
public Build getRun() {
    return this.dynamicBuild.getRun(this.combination);
}
项目:jenkins.py    文件:BuilderPW.java   
public boolean superPerform(Build<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
    return super.perform(build, launcher, listener);
}
项目:jenkins.py    文件:RecorderPW.java   
public boolean superPerform(Build<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
    return super.perform(build, launcher, listener);
}
项目:jenkins.py    文件:NotifierPW.java   
public boolean superPerform(Build<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
    return super.perform(build, launcher, listener);
}
项目:jenkins-inheritance-plugin    文件:InheritanceGovernor.java   
public static boolean inheritanceLookupRequired(InheritanceProject root, boolean forcedInherit) {
    //In a cyclic dependency, any form of inheritance would be ill-advised
    try {
        if (root.hasCyclicDependency()) {
            return false;
        }
    } catch (NullPointerException ex) {
        //The project might not be loaded completely yet; this will cause
        //an NPE which means no inheritance should be queried
        return false;
    }
    /* Otherwise, an exploration is only required when one of the following
     * holds:
     * 1.) The user wants to force inheritance
     * 2.) The project is transient and has no real own configuration
     * 3.) The project is called in the context of a build
     * 4.) The queue queries properties of the project 
     */

    //Check forced inheritance or transience
    if (forcedInherit || root.getIsTransient()) {
        return true;
    }

    //Checking the Stapler Request, because it is fast
    StaplerRequest req = Stapler.getCurrentRequest();
    if (req != null) {
        String uri = req.getRequestURI();
        //Check if we request the build page
        if (uri.endsWith("/build")) {
            return true;
        }
        //Check if we were requested by page for a run
        if (runUriRegExp.matcher(uri).matches()) {
            return true;
        }
    }

    //Check via expensive stack reflection
    if (Reflection.calledFromClass(
            Build.class, BuildCommand.class,
            Queue.class, BuildTrigger.class,
            Trigger.class, BuildStep.class
        ) ||
        Reflection.calledFromMethod(
                InheritanceProject.class,
                "doBuild", "scheduleBuild2", "doBuildWithParameters"
        )
    ) {
        return true;
    }

    //In all other cases, we don't require (or want) inheritance
    return false;
}