Search in sources :

Example 1 with Executable

use of hudson.model.Queue.Executable in project hudson-2.x by hudson.

the class Executor method getEstimatedRemainingTime.

/**
     * Computes a human-readable text that shows the expected remaining time
     * until the build completes.
     */
public String getEstimatedRemainingTime() {
    Queue.Executable e = executable;
    if (e == null)
        return Messages.Executor_NotAvailable();
    long d = Executables.getEstimatedDurationFor(e);
    if (d < 0)
        return Messages.Executor_NotAvailable();
    long eta = d - getElapsedTime();
    if (eta <= 0)
        return Messages.Executor_NotAvailable();
    return Util.getTimeSpanString(eta);
}
Also used : Executable(hudson.model.Queue.Executable)

Example 2 with Executable

use of hudson.model.Queue.Executable in project hudson-2.x by hudson.

the class Executor method getEstimatedRemainingTimeMillis.

/**
     * The same as {@link #getEstimatedRemainingTime()} but return
     * it as a number of milli-seconds.
     */
public long getEstimatedRemainingTimeMillis() {
    Queue.Executable e = executable;
    if (e == null)
        return -1;
    long d = Executables.getEstimatedDurationFor(e);
    if (d < 0)
        return -1;
    long eta = d - getElapsedTime();
    if (eta <= 0)
        return -1;
    return eta;
}
Also used : Executable(hudson.model.Queue.Executable)

Example 3 with Executable

use of hudson.model.Queue.Executable in project hudson-2.x by hudson.

the class AbstractProject method getBuildForDeprecatedMethods.

/**
     * Various deprecated methods in this class all need the 'current' build.  This method returns
     * the build suitable for that purpose.
     *
     * @return An AbstractBuild for deprecated methods to use.
     */
private AbstractBuild getBuildForDeprecatedMethods() {
    Executor e = Executor.currentExecutor();
    if (e != null) {
        Executable exe = e.getCurrentExecutable();
        if (exe instanceof AbstractBuild) {
            AbstractBuild b = (AbstractBuild) exe;
            if (b.getProject() == this)
                return b;
        }
    }
    R lb = getLastBuild();
    if (lb != null)
        return lb;
    return null;
}
Also used : SC_INTERNAL_SERVER_ERROR(javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR) Executable(hudson.model.Queue.Executable)

Example 4 with Executable

use of hudson.model.Queue.Executable in project hudson-2.x by hudson.

the class Executor method doStop.

/**
     * Stops the current build.
     */
public void doStop(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
    Queue.Executable e = executable;
    if (e != null) {
        Tasks.getOwnerTaskOf(getParentOf(e)).checkAbortPermission();
        interrupt();
    }
    rsp.forwardToPreviousPage(req);
}
Also used : Executable(hudson.model.Queue.Executable)

Example 5 with Executable

use of hudson.model.Queue.Executable in project hudson-2.x by hudson.

the class Executor method getProgress.

/**
     * Returns the progress of the current build in the number between 0-100.
     *
     * @return -1
     *      if it's impossible to estimate the progress.
     */
@Exported
public int getProgress() {
    Queue.Executable e = executable;
    if (e == null)
        return -1;
    long d = Executables.getEstimatedDurationFor(e);
    if (d < 0)
        return -1;
    int num = (int) (getElapsedTime() * 100 / d);
    if (num >= 100)
        num = 99;
    return num;
}
Also used : Executable(hudson.model.Queue.Executable) Exported(org.kohsuke.stapler.export.Exported)

Aggregations

Executable (hudson.model.Queue.Executable)6 Exported (org.kohsuke.stapler.export.Exported)2 SC_INTERNAL_SERVER_ERROR (javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR)1