Java Code Examples for hudson.model.AbstractProject#getLastBuild()

The following examples show how to use hudson.model.AbstractProject#getLastBuild() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FingerprintTestUtil.java    From docker-traceability-plugin with MIT License 6 votes vote down vote up
/**
 * A stub method, which emulates the submission of the image reference 
 * from the web interface
 * @param req Incoming request
 * @param rsp Response
 * @param imageId image id
 * @param jobName job name, to which the facet should be attached
 * @throws IOException Request processing error
 * @throws ServletException Servlet error
 */
public static void doTestSubmitBuildRef(StaplerRequest req, StaplerResponse rsp,
        @QueryParameter(required = true) String imageId,
        @QueryParameter(required = true) String jobName) throws IOException, ServletException {
    final Jenkins j = Jenkins.getInstance();
    if (j == null) {
        throw new IOException("Jenkins instance is not active");
    }
    j.checkPermission(Jenkins.ADMINISTER);
    
    final AbstractProject item = j.getItem(jobName, j, AbstractProject.class);
    final Run latest = item != null ? item.getLastBuild() : null;
    if (latest == null) {
        throw new IOException("Cannot find a project or run to modify"); 
    }
    
    DockerFingerprints.addFromFacet(null,imageId, latest);
    rsp.sendRedirect2(j.getRootUrl());
}
 
Example 2
Source File: AWSDeviceFarmUtils.java    From aws-device-farm-jenkins-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the most recent build which contained an AWS Device Farm test run.
 *
 * @param project The Jenkins project which contains runs to examine.
 * @return The previous Device Farm build.
 */
public static AbstractBuild<?, ?> previousAWSDeviceFarmBuild(AbstractProject<?, ?> project) {
    AbstractBuild<?, ?> last = project.getLastBuild();
    while (last != null) {
        if (last.getAction(AWSDeviceFarmTestResultAction.class) != null) {
            break;
        }
        last = last.getPreviousBuild();
    }
    return last;
}
 
Example 3
Source File: AWSDeviceFarmUtils.java    From aws-device-farm-jenkins-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Return collection of all previous builds of the given project which contain an AWS Device Farm test run.
 *
 * @param project The Jenkins project which contains runs to examine.
 * @return The previous Device Farm builds.
 */
public static ArrayList<AWSDeviceFarmTestResultAction> previousAWSDeviceFarmBuilds(AbstractProject<?, ?> project) {
    ArrayList<AWSDeviceFarmTestResultAction> actions = new ArrayList<AWSDeviceFarmTestResultAction>();

    AbstractBuild<?, ?> build = project.getLastBuild();
    while (build != null) {
        AWSDeviceFarmTestResultAction action = build.getAction(AWSDeviceFarmTestResultAction.class);
        if (action != null) {
            actions.add(action);
        }
        build = build.getPreviousBuild();
    }
    return actions;
}