Dan Tao
Dan Tao

Reputation: 128317

Is there a way to tell how far Jenkins has gotten in cloning a Git repo?

I've got a build running in Jenkins right now and all I can see in the console output is:

Started by user anonymous
Building in workspace /var/lib/jenkins/workspace/Main
Checkout:Main / /var/lib/jenkins/workspace/Main - hudson.remoting.LocalChannel@820ea4
Using strategy: Default
Cloning the remote Git repository
Cloning repository origin

I understand this is probably because the Git process has not flushed its output stream yet; but it's frustrating because if I run a git clone from the terminal then I can clearly see a percentage updated in real time telling me how close the command is to being finished.

It wouldn't really matter except that:

  1. I need to shut down this machine soon.
  2. This particular repo takes a long time to clone (like over an hour).
  3. Therefore, if the clone is at, say, 90%, I want to let it finish. If it's more like 50% then I want to just kill the build and start it over in the morning.

Does anybody know if it's possible to somehow get the information I crave?

Upvotes: 5

Views: 1182

Answers (2)

jstricker
jstricker

Reputation: 2180

I saw similar symptoms, and I found that it was caused by a recursive delete of the workspace in the Jenkin's Git plugin clone() method (see code snippet, below). In my case, we have numerous jobs that share a single custom workspace, so the delete call took hours to complete. After removing the custom workspace, the clone operation finished successfully.

From https://github.com/jenkinsci/git-plugin/blob/master/src/main/java/hudson/plugins/git/GitAPI.java:

final String source = remoteConfig.getURIs().get(0).toPrivateString();

listener.getLogger().println("Cloning repository " + source);
final int[] gitVer = getGitVersion();

try {
    workspace.deleteRecursive();  // This line was taking forever
} catch (Exception e) {
    e.printStackTrace(listener.error("Failed to clean the workspace"));
    throw new GitException("Failed to delete workspace", e);
}

(This should be a comment on the previous answer, but I don't have the rep to make comments yet.)

Upvotes: 0

Tyler Smith
Tyler Smith

Reputation: 1279

Search for clone and see where it checks the git version to determine if it passes the --progress flag. If your build is already going there is not much you can do, but for future reference this may be helpful.

--progress
       Progress status is reported on the standard error stream by default
       when it is attached to a terminal, unless -q is specified. This
       flag forces progress status even if the standard error stream is
       not directed to a terminal.

Upvotes: 2

Related Questions